[svn] / branches / release-1_0-branch / xvidcore / examples / xvid_decraw.c Repository:
ViewVC logotype

Annotation of /branches/release-1_0-branch/xvidcore/examples/xvid_decraw.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1414 - (view) (download)

1 : edgomez 547 /*****************************************************************************
2 : chl 376 *
3 : edgomez 547 * XVID MPEG-4 VIDEO CODEC
4 :     * - Console based decoding test application -
5 : chl 376 *
6 : edgomez 851 * Copyright(C) 2002-2003 Christoph Lampert
7 : edgomez 1382 * 2002-2003 Edouard Gomez <ed.gomez@free.fr>
8 : chl 376 *
9 : edgomez 547 * This program is free software; you can redistribute it and/or modify
10 :     * it under the terms of the GNU General Public License as published by
11 :     * the Free Software Foundation; either version 2 of the License, or
12 :     * (at your option) any later version.
13 : chl 376 *
14 : edgomez 547 * This program is distributed in the hope that it will be useful,
15 :     * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 :     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 :     * GNU General Public License for more details.
18 : chl 376 *
19 : edgomez 547 * You should have received a copy of the GNU General Public License
20 :     * 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 :     *
23 : edgomez 1414 * $Id: xvid_decraw.c,v 1.10.2.1 2004-04-07 22:02:56 edgomez Exp $
24 : edgomez 547 *
25 :     ****************************************************************************/
26 : chl 376
27 : edgomez 547 /*****************************************************************************
28 : chl 376 *
29 : edgomez 547 * Application notes :
30 : chl 376 *
31 : edgomez 547 * An MPEG-4 bitstream is read from an input file (or stdin) and decoded,
32 :     * the speed for this is measured.
33 : edgomez 1382 *
34 :     * The program is plain C and needs no libraries except for libxvidcore,
35 :     * and maths-lib.
36 : chl 376 *
37 : edgomez 1382 * Use ./xvid_decraw -help for a list of options
38 : chl 376 *
39 : edgomez 547 ****************************************************************************/
40 : chl 376
41 :     #include <stdio.h>
42 :     #include <stdlib.h>
43 : edgomez 547 #include <string.h>
44 :     #include <math.h>
45 : edgomez 824 #ifndef WIN32
46 : edgomez 547 #include <sys/time.h>
47 :     #else
48 :     #include <time.h>
49 :     #endif
50 : chl 376
51 : edgomez 547 #include "xvid.h"
52 : chl 376
53 : edgomez 547 /*****************************************************************************
54 :     * Global vars in module and constants
55 :     ****************************************************************************/
56 : chl 376
57 : edgomez 547 /* max number of frames */
58 :     #define ABS_MAXFRAMENR 9999
59 : chl 376
60 : edgomez 547 static int XDIM = 0;
61 :     static int YDIM = 0;
62 :     static int ARG_SAVEDECOUTPUT = 0;
63 :     static int ARG_SAVEMPEGSTREAM = 0;
64 :     static char *ARG_INPUTFILE = NULL;
65 : edgomez 1414 static int CSP = XVID_CSP_I420;
66 :     static int BPP = 1;
67 : chl 376
68 : edgomez 547 static char filepath[256] = "./";
69 :     static void *dec_handle = NULL;
70 : chl 376
71 : edgomez 1382 #define BUFFER_SIZE (2*1024*1024)
72 : chl 376
73 : edgomez 547 /*****************************************************************************
74 :     * Local prototypes
75 :     ****************************************************************************/
76 : chl 376
77 : edgomez 547 static double msecond();
78 :     static int write_pgm(char *filename,
79 : edgomez 1382 unsigned char *image);
80 : edgomez 547 static int dec_init(int use_assembler);
81 :     static int dec_main(unsigned char *istream,
82 : edgomez 851 unsigned char *ostream,
83 :     int istream_size,
84 : edgomez 1382 xvid_dec_stats_t *xvid_dec_stats);
85 : edgomez 547 static int dec_stop();
86 :     static void usage();
87 :    
88 : edgomez 1382
89 :     const char * type2str(int type)
90 :     {
91 :     if (type==XVID_TYPE_IVOP)
92 :     return "I";
93 :     if (type==XVID_TYPE_PVOP)
94 :     return "P";
95 :     if (type==XVID_TYPE_BVOP)
96 :     return "B";
97 :     return "S";
98 :     }
99 :    
100 : edgomez 547 /*****************************************************************************
101 :     * Main program
102 :     ****************************************************************************/
103 :    
104 :     int main(int argc, char *argv[])
105 : chl 376 {
106 : edgomez 547 unsigned char *mp4_buffer = NULL;
107 :     unsigned char *mp4_ptr = NULL;
108 :     unsigned char *out_buffer = NULL;
109 : edgomez 1382 int useful_bytes;
110 :     xvid_dec_stats_t xvid_dec_stats;
111 : edgomez 851
112 : edgomez 547 double totaldectime;
113 :    
114 :     long totalsize;
115 :     int status;
116 :    
117 :     int use_assembler = 0;
118 :    
119 :     char filename[256];
120 :    
121 :     FILE *in_file;
122 :     int filenr;
123 :     int i;
124 :    
125 :     printf("xvid_decraw - raw mpeg4 bitstream decoder ");
126 : edgomez 851 printf("written by Christoph Lampert 2002-2003\n\n");
127 : edgomez 547
128 :     /*****************************************************************************
129 :     * Command line parsing
130 :     ****************************************************************************/
131 :    
132 :     for (i=1; i< argc; i++) {
133 :    
134 :     if (strcmp("-asm", argv[i]) == 0 ) {
135 :     use_assembler = 1;
136 : edgomez 1382 } else if (strcmp("-d", argv[i]) == 0) {
137 :     ARG_SAVEDECOUTPUT = 1;
138 :     } else if (strcmp("-i", argv[i]) == 0 && i < argc - 1 ) {
139 : edgomez 547 i++;
140 :     ARG_INPUTFILE = argv[i];
141 : edgomez 1382 } else if (strcmp("-m", argv[i]) == 0) {
142 :     ARG_SAVEMPEGSTREAM = 1;
143 : edgomez 1414 } else if (strcmp("-c", argv[i]) == 0 && i < argc - 1 ) {
144 :     i++;
145 :     if (strcmp(argv[i], "rgb16") == 0) {
146 :     CSP = XVID_CSP_RGB555;
147 :     BPP = 2;
148 :     } else if (strcmp(argv[i], "rgb24") == 0) {
149 :     CSP = XVID_CSP_BGR;
150 :     BPP = 3;
151 :     } else if (strcmp(argv[i], "rgb32") == 0) {
152 :     CSP = XVID_CSP_BGRA;
153 :     BPP = 4;
154 :     } else if (strcmp(argv[i], "yv12") == 0) {
155 :     CSP = XVID_CSP_YV12;
156 :     BPP = 1;
157 :     } else {
158 :     CSP = XVID_CSP_I420;
159 :     BPP = 1;
160 :     }
161 : edgomez 1382 } else if (strcmp("-help", argv[i]) == 0) {
162 : edgomez 547 usage();
163 :     return(0);
164 : edgomez 1382 } else {
165 : edgomez 547 usage();
166 :     exit(-1);
167 :     }
168 : chl 376 }
169 : edgomez 547
170 :     /*****************************************************************************
171 :     * Values checking
172 :     ****************************************************************************/
173 :    
174 :     if ( ARG_INPUTFILE == NULL || strcmp(ARG_INPUTFILE, "stdin") == 0) {
175 :     in_file = stdin;
176 :     }
177 :     else {
178 :    
179 :     in_file = fopen(ARG_INPUTFILE, "rb");
180 :     if (in_file == NULL) {
181 :     fprintf(stderr, "Error opening input file %s\n", ARG_INPUTFILE);
182 : edgomez 1382 return(-1);
183 : edgomez 547 }
184 :     }
185 :    
186 :     /*****************************************************************************
187 :     * Memory allocation
188 :     ****************************************************************************/
189 :    
190 :     /* Memory for encoded mp4 stream */
191 :     mp4_buffer = (unsigned char *) malloc(BUFFER_SIZE);
192 :     mp4_ptr = mp4_buffer;
193 :     if (!mp4_buffer)
194 :     goto free_all_memory;
195 :    
196 :     /*****************************************************************************
197 :     * XviD PART Start
198 :     ****************************************************************************/
199 :    
200 :     status = dec_init(use_assembler);
201 :     if (status) {
202 :     fprintf(stderr,
203 : edgomez 1382 "Decore INIT problem, return value %d\n", status);
204 : edgomez 547 goto release_all;
205 :     }
206 :    
207 :    
208 :     /*****************************************************************************
209 :     * Main loop
210 :     ****************************************************************************/
211 :    
212 : edgomez 851 /* Fill the buffer */
213 : edgomez 1382 useful_bytes = fread(mp4_buffer, 1, BUFFER_SIZE, in_file);
214 : edgomez 559
215 : edgomez 547 totaldectime = 0;
216 :     totalsize = 0;
217 :     filenr = 0;
218 :     mp4_ptr = mp4_buffer;
219 :    
220 :     do {
221 :     int used_bytes = 0;
222 :     double dectime;
223 :    
224 : edgomez 851 /*
225 :     * If the buffer is half empty or there are no more bytes in it
226 :     * then fill it.
227 :     */
228 : edgomez 1382 if (mp4_ptr > mp4_buffer + BUFFER_SIZE/2) {
229 :     int already_in_buffer = (mp4_buffer + BUFFER_SIZE - mp4_ptr);
230 : edgomez 547
231 : edgomez 851 /* Move data if needed */
232 : edgomez 1382 if (already_in_buffer > 0)
233 :     memcpy(mp4_buffer, mp4_ptr, already_in_buffer);
234 : edgomez 547
235 : edgomez 851 /* Update mp4_ptr */
236 :     mp4_ptr = mp4_buffer;
237 : edgomez 547
238 : edgomez 851 /* read new data */
239 : edgomez 1382 if(feof(in_file))
240 : edgomez 547 break;
241 :    
242 : edgomez 1382 useful_bytes += fread(mp4_buffer + already_in_buffer,
243 :     1, BUFFER_SIZE - already_in_buffer,
244 :     in_file);
245 : edgomez 547
246 :     }
247 :    
248 :    
249 : edgomez 1382 /* This loop is needed to handle VOL/NVOP reading */
250 : edgomez 851 do {
251 : edgomez 547
252 : edgomez 851 /* Decode frame */
253 :     dectime = msecond();
254 : edgomez 1382 used_bytes = dec_main(mp4_ptr, out_buffer, useful_bytes, &xvid_dec_stats);
255 : edgomez 851 dectime = msecond() - dectime;
256 : edgomez 547
257 : edgomez 1382 /* Resize image buffer if needed */
258 :     if(xvid_dec_stats.type == XVID_TYPE_VOL) {
259 :    
260 :     /* Check if old buffer is smaller */
261 :     if(XDIM*YDIM < xvid_dec_stats.data.vol.width*xvid_dec_stats.data.vol.height) {
262 :    
263 :     /* Copy new witdh and new height from the vol structure */
264 :     XDIM = xvid_dec_stats.data.vol.width;
265 :     YDIM = xvid_dec_stats.data.vol.height;
266 :    
267 :     /* Free old output buffer*/
268 :     if(out_buffer) free(out_buffer);
269 :    
270 :     /* Allocate the new buffer */
271 :     out_buffer = (unsigned char*)malloc(XDIM*YDIM*4);
272 :     if(out_buffer == NULL)
273 :     goto free_all_memory;
274 :    
275 :     fprintf(stderr, "Resized frame buffer to %dx%d\n", XDIM, YDIM);
276 :     }
277 : edgomez 851 }
278 : edgomez 547
279 : edgomez 851 /* Update buffer pointers */
280 : edgomez 1382 if(used_bytes > 0) {
281 :     mp4_ptr += used_bytes;
282 :     useful_bytes -= used_bytes;
283 : edgomez 559
284 : edgomez 1382 /* Total size */
285 :     totalsize += used_bytes;
286 :     }
287 : edgomez 547
288 : edgomez 1382 }while(xvid_dec_stats.type <= 0 && useful_bytes > 0);
289 : edgomez 547
290 : edgomez 1382 /* Check if there is a negative number of useful bytes left in buffer
291 :     * This means we went too far */
292 :     if(useful_bytes < 0)
293 :     break;
294 : edgomez 851
295 : edgomez 1382 /* Updated data - Count only usefull decode time */
296 : edgomez 851 totaldectime += dectime;
297 : edgomez 547
298 : edgomez 851
299 : edgomez 1382 printf("Frame %5d: type = %s, dectime(ms) =%6.1f, length(bytes) =%7d\n",
300 :     filenr, type2str(xvid_dec_stats.type), dectime, used_bytes);
301 :    
302 : edgomez 851 /* Save individual mpeg4 stream if required */
303 : edgomez 1382 if(ARG_SAVEMPEGSTREAM) {
304 : edgomez 547 FILE *filehandle = NULL;
305 :    
306 :     sprintf(filename, "%sframe%05d.m4v", filepath, filenr);
307 :     filehandle = fopen(filename, "wb");
308 :     if(!filehandle) {
309 :     fprintf(stderr,
310 : edgomez 851 "Error writing single mpeg4 stream to file %s\n",
311 :     filename);
312 : edgomez 547 }
313 :     else {
314 : edgomez 1382 fwrite(mp4_ptr-used_bytes, 1, used_bytes, filehandle);
315 : edgomez 547 fclose(filehandle);
316 :     }
317 :     }
318 : edgomez 851
319 : edgomez 547 /* Save output frame if required */
320 :     if (ARG_SAVEDECOUTPUT) {
321 : edgomez 1414 sprintf(filename, "%sdec%05d.tga", filepath, filenr);
322 :     if(write_tga(filename,out_buffer)) {
323 : edgomez 547 fprintf(stderr,
324 : edgomez 851 "Error writing decoded PGM frame %s\n",
325 :     filename);
326 : edgomez 547 }
327 :     }
328 :    
329 :     filenr++;
330 :    
331 : edgomez 851 } while ( (status>=0) && (filenr<ABS_MAXFRAMENR));
332 : edgomez 547
333 :     /*****************************************************************************
334 : edgomez 851 * Flush decoder buffers
335 :     ****************************************************************************/
336 :    
337 : edgomez 1382 do {
338 :    
339 : edgomez 851 /* Fake vars */
340 : edgomez 1382 int used_bytes;
341 : edgomez 851 double dectime;
342 :    
343 : edgomez 1382 do {
344 :     dectime = msecond();
345 :     used_bytes = dec_main(NULL, out_buffer, -1, &xvid_dec_stats);
346 :     dectime = msecond() - dectime;
347 :     }while(used_bytes>=0 && xvid_dec_stats.type <= 0);
348 : edgomez 851
349 : edgomez 1382 if (used_bytes < 0) { /* XVID_ERR_END */
350 :     break;
351 :     }
352 : edgomez 851
353 :     /* Updated data - Count only usefull decode time */
354 :     totaldectime += dectime;
355 :    
356 :     /* Prints some decoding stats */
357 : edgomez 1382 printf("Frame %5d: type = %s, dectime(ms) =%6.1f, length(bytes) =%7d\n",
358 :     filenr, type2str(xvid_dec_stats.type), dectime, used_bytes);
359 : edgomez 851
360 :     /* Save output frame if required */
361 :     if (ARG_SAVEDECOUTPUT) {
362 : edgomez 1414 sprintf(filename, "%sdec%05d.tga", filepath, filenr);
363 :     if(write_tga(filename, out_buffer)) {
364 : edgomez 851 fprintf(stderr,
365 :     "Error writing decoded PGM frame %s\n",
366 :     filename);
367 :     }
368 :     }
369 :    
370 :     filenr++;
371 :    
372 : edgomez 1382 }while(1);
373 : edgomez 851
374 :     /*****************************************************************************
375 : edgomez 547 * Calculate totals and averages for output, print results
376 :     ****************************************************************************/
377 :    
378 :     totalsize /= filenr;
379 :     totaldectime /= filenr;
380 :    
381 : edgomez 851 printf("Avg: dectime(ms) =%7.2f, fps =%7.2f, length(bytes) =%7d\n",
382 : edgomez 1382 totaldectime, 1000/totaldectime, (int)totalsize);
383 : edgomez 547
384 :     /*****************************************************************************
385 :     * XviD PART Stop
386 : edgomez 559 ****************************************************************************/
387 : edgomez 547
388 :     release_all:
389 :     if (dec_handle) {
390 :     status = dec_stop();
391 :     if (status)
392 :     fprintf(stderr, "decore RELEASE problem return value %d\n", status);
393 :     }
394 :    
395 :     free_all_memory:
396 :     free(out_buffer);
397 :     free(mp4_buffer);
398 :    
399 : edgomez 1382 return(0);
400 : chl 376 }
401 :    
402 : edgomez 547 /*****************************************************************************
403 :     * Usage function
404 :     ****************************************************************************/
405 : chl 376
406 : edgomez 547 static void usage()
407 : chl 376 {
408 : edgomez 547
409 : edgomez 1382 fprintf(stderr, "Usage : xvid_decraw [OPTIONS]\n");
410 : edgomez 547 fprintf(stderr, "Options :\n");
411 :     fprintf(stderr, " -asm : use assembly optimizations (default=disabled)\n");
412 :     fprintf(stderr, " -i string : input filename (default=stdin)\n");
413 : edgomez 1382 fprintf(stderr, " -d : save decoder output\n");
414 : edgomez 1414 fprintf(stderr, " -c csp : choose colorspace output (csp can be one of rgb16, rgb24, rgb32, yv12, i420)\n");
415 : edgomez 1382 fprintf(stderr, " -m : save mpeg4 raw stream to individual files\n");
416 : edgomez 547 fprintf(stderr, " -help : This help message\n");
417 :     fprintf(stderr, " (* means default)\n");
418 :    
419 :     }
420 :    
421 :     /*****************************************************************************
422 :     * "helper" functions
423 :     ****************************************************************************/
424 :    
425 :     /* return the current time in milli seconds */
426 :     static double
427 :     msecond()
428 :     {
429 : edgomez 824 #ifndef WIN32
430 : edgomez 547 struct timeval tv;
431 :     gettimeofday(&tv, 0);
432 : edgomez 1382 return((double)tv.tv_sec*1.0e3 + (double)tv.tv_usec*1.0e-3);
433 : edgomez 547 #else
434 :     clock_t clk;
435 :     clk = clock();
436 : edgomez 1382 return(clk * 1000 / CLOCKS_PER_SEC);
437 : edgomez 547 #endif
438 :     }
439 :    
440 :     /*****************************************************************************
441 :     * output functions
442 :     ****************************************************************************/
443 :    
444 : edgomez 1414 int write_tga(char *filename, unsigned char *image)
445 : edgomez 547 {
446 : edgomez 1414 FILE * f;
447 :     char hdr[18];
448 : edgomez 547
449 : edgomez 1414 f = fopen(filename, "wb");
450 :     if ( f == NULL) {
451 :     return -1;
452 :     }
453 : edgomez 547
454 : edgomez 1414 hdr[0] = 0; /* ID length */
455 :     hdr[1] = 0; /* Color map type */
456 :     hdr[2] = (BPP>1)?2:3; /* Uncompressed true color (2) or greymap (3) */
457 :     hdr[3] = 0; /* Color map specification (not used) */
458 :     hdr[4] = 0; /* Color map specification (not used) */
459 :     hdr[5] = 0; /* Color map specification (not used) */
460 :     hdr[6] = 0; /* Color map specification (not used) */
461 :     hdr[7] = 0; /* Color map specification (not used) */
462 :     hdr[8] = 0; /* LSB X origin */
463 :     hdr[9] = 0; /* MSB X origin */
464 :     hdr[10] = 0; /* LSB Y origin */
465 :     hdr[11] = 0; /* MSB Y origin */
466 :     hdr[12] = (XDIM>>0)&0xff; /* LSB Width */
467 :     hdr[13] = (XDIM>>8)&0xff; /* MSB Width */
468 :     if (BPP > 1) {
469 :     hdr[14] = (YDIM>>0)&0xff; /* LSB Height */
470 :     hdr[15] = (YDIM>>8)&0xff; /* MSB Height */
471 :     } else {
472 :     hdr[14] = ((YDIM*3)>>1)&0xff; /* LSB Height */
473 :     hdr[15] = ((YDIM*3)>>9)&0xff; /* MSB Height */
474 :     }
475 :     hdr[16] = BPP*8;
476 :     hdr[17] = 0x00 | (1<<5) /* Up to down */ | (0<<4); /* Image descriptor */
477 :    
478 :     /* Write header */
479 :     fwrite(hdr, 1, sizeof(hdr), f);
480 : chl 376
481 : edgomez 1414 #ifdef ARCH_IS_LITTLE_ENDIAN
482 :     /* write first plane */
483 :     fwrite(image, 1, XDIM*YDIM*BPP, f);
484 :     #else
485 :     {
486 :     int i;
487 :     for (i=0; i<width*height*BPP;i+=BPP) {
488 :     if (BPP == 1) {
489 :     fputc(image+i, f);
490 :     } else if (BPP == 2) {
491 :     fputc(image+i+1, f);
492 :     fputc(image+i+0, f);
493 :     } else if (BPP == 3) {
494 :     fputc(image+i+2, f);
495 :     fputc(image+i+1, f);
496 :     fputc(image+i+0, f);
497 :     } else if (BPP == 4) {
498 :     fputc(image+i+3, f);
499 :     fputc(image+i+2, f);
500 :     fputc(image+i+1, f);
501 :     fputc(image+i+0, f);
502 :     }
503 :     }
504 :     }
505 :     #endif
506 : edgomez 547
507 : edgomez 1414 /* Write Y and V planes for YUV formats */
508 :     if (BPP == 1) {
509 :     int i;
510 : edgomez 547
511 : edgomez 1414 /* Write the two chrominance planes */
512 :     for (i=0; i<YDIM/2; i++) {
513 :     fwrite(image+XDIM*YDIM+XDIM/2*i, 1, XDIM/2, f);
514 :     fwrite(image+5*XDIM*YDIM/4 + XDIM/2*i, 1, XDIM/2, f);
515 :     }
516 :     }
517 : edgomez 547
518 :    
519 : edgomez 1414 /* Close the file */
520 :     fclose(f);
521 : edgomez 547
522 : edgomez 1414 return(0);
523 : chl 376 }
524 :    
525 : edgomez 547 /*****************************************************************************
526 :     * Routines for decoding: init decoder, use, and stop decoder
527 :     ****************************************************************************/
528 : chl 376
529 : edgomez 547 /* init decoder before first run */
530 :     static int
531 :     dec_init(int use_assembler)
532 : chl 376 {
533 : edgomez 1382 int ret;
534 : chl 376
535 : edgomez 1382 xvid_gbl_init_t xvid_gbl_init;
536 :     xvid_dec_create_t xvid_dec_create;
537 : chl 376
538 : edgomez 1382 /*------------------------------------------------------------------------
539 :     * XviD core initialization
540 :     *----------------------------------------------------------------------*/
541 :    
542 :     /* Version */
543 :     xvid_gbl_init.version = XVID_VERSION;
544 :    
545 :     /* Assembly setting */
546 :     if(use_assembler)
547 : suxen_drol 860 #ifdef ARCH_IS_IA64
548 : edgomez 1382 xvid_gbl_init.cpu_flags = XVID_CPU_FORCE | XVID_CPU_IA64;
549 : chl 376 #else
550 : edgomez 1382 xvid_gbl_init.cpu_flags = 0;
551 : chl 376 #endif
552 : edgomez 1382 else
553 :     xvid_gbl_init.cpu_flags = XVID_CPU_FORCE;
554 : chl 376
555 : edgomez 1382 xvid_global(NULL, 0, &xvid_gbl_init, NULL);
556 : chl 376
557 : edgomez 1382 /*------------------------------------------------------------------------
558 :     * XviD encoder initialization
559 :     *----------------------------------------------------------------------*/
560 : edgomez 851
561 : edgomez 1382 /* Version */
562 :     xvid_dec_create.version = XVID_VERSION;
563 : chl 376
564 : edgomez 1382 /*
565 :     * Image dimensions -- set to 0, xvidcore will resize when ever it is
566 :     * needed
567 :     */
568 :     xvid_dec_create.width = 0;
569 :     xvid_dec_create.height = 0;
570 :    
571 :     ret = xvid_decore(NULL, XVID_DEC_CREATE, &xvid_dec_create, NULL);
572 :    
573 :     dec_handle = xvid_dec_create.handle;
574 :    
575 :     return(ret);
576 : chl 376 }
577 :    
578 : edgomez 547 /* decode one frame */
579 :     static int
580 :     dec_main(unsigned char *istream,
581 : edgomez 851 unsigned char *ostream,
582 :     int istream_size,
583 : edgomez 1382 xvid_dec_stats_t *xvid_dec_stats)
584 : edgomez 547 {
585 : chl 376
586 : edgomez 1382 int ret;
587 : chl 376
588 : edgomez 1382 xvid_dec_frame_t xvid_dec_frame;
589 : chl 376
590 : edgomez 1382 /* Set version */
591 :     xvid_dec_frame.version = XVID_VERSION;
592 :     xvid_dec_stats->version = XVID_VERSION;
593 : chl 376
594 : edgomez 1382 /* No general flags to set */
595 :     xvid_dec_frame.general = 0;
596 : chl 376
597 : edgomez 1382 /* Input stream */
598 :     xvid_dec_frame.bitstream = istream;
599 :     xvid_dec_frame.length = istream_size;
600 : edgomez 851
601 : edgomez 1382 /* Output frame structure */
602 :     xvid_dec_frame.output.plane[0] = ostream;
603 : edgomez 1414 xvid_dec_frame.output.stride[0] = XDIM*BPP;
604 :     xvid_dec_frame.output.csp = CSP;
605 : edgomez 1382
606 :     ret = xvid_decore(dec_handle, XVID_DEC_DECODE, &xvid_dec_frame, xvid_dec_stats);
607 :    
608 :     return(ret);
609 : chl 376 }
610 :    
611 : edgomez 547 /* close decoder to release resources */
612 :     static int
613 :     dec_stop()
614 : chl 376 {
615 : edgomez 1382 int ret;
616 : edgomez 547
617 : edgomez 1382 ret = xvid_decore(dec_handle, XVID_DEC_DESTROY, NULL, NULL);
618 : chl 376
619 : edgomez 1382 return(ret);
620 : chl 376 }

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