20 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
* |
* |
23 |
* $Id: xvid_decraw.c,v 1.12 2004-04-12 14:05:08 edgomez Exp $ |
* $Id: xvid_decraw.c,v 1.16 2004-07-17 11:42:46 edgomez Exp $ |
24 |
* |
* |
25 |
****************************************************************************/ |
****************************************************************************/ |
26 |
|
|
79 |
****************************************************************************/ |
****************************************************************************/ |
80 |
|
|
81 |
static double msecond(); |
static double msecond(); |
|
static int write_pgm(char *filename, |
|
|
unsigned char *image); |
|
82 |
static int dec_init(int use_assembler, int debug_level); |
static int dec_init(int use_assembler, int debug_level); |
83 |
static int dec_main(unsigned char *istream, |
static int dec_main(unsigned char *istream, |
84 |
unsigned char *ostream, |
unsigned char *ostream, |
86 |
xvid_dec_stats_t *xvid_dec_stats); |
xvid_dec_stats_t *xvid_dec_stats); |
87 |
static int dec_stop(); |
static int dec_stop(); |
88 |
static void usage(); |
static void usage(); |
89 |
|
static int write_image(char *prefix, unsigned char *image); |
90 |
|
static int write_pnm(char *filename, unsigned char *image); |
91 |
|
static int write_tga(char *filename, unsigned char *image); |
92 |
|
|
93 |
const char * type2str(int type) |
const char * type2str(int type) |
94 |
{ |
{ |
184 |
} |
} |
185 |
} |
} |
186 |
|
|
187 |
|
#if defined(_MSC_VER) |
188 |
|
if (ARG_INPUTFILE==NULL) { |
189 |
|
fprintf(stderr, "Warning: MSVC build does not read EOF correctly from stdin. Use the -i switch.\n\n"); |
190 |
|
} |
191 |
|
#endif |
192 |
|
|
193 |
/***************************************************************************** |
/***************************************************************************** |
194 |
* Values checking |
* Values checking |
195 |
****************************************************************************/ |
****************************************************************************/ |
349 |
sprintf(filename, "%sdec%05d", filepath, filenr); |
sprintf(filename, "%sdec%05d", filepath, filenr); |
350 |
if(write_image(filename, out_buffer)) { |
if(write_image(filename, out_buffer)) { |
351 |
fprintf(stderr, |
fprintf(stderr, |
352 |
"Error writing decoded PGM frame %s\n", |
"Error writing decoded frame %s\n", |
353 |
filename); |
filename); |
354 |
} |
} |
355 |
} |
} |
390 |
sprintf(filename, "%sdec%05d", filepath, filenr); |
sprintf(filename, "%sdec%05d", filepath, filenr); |
391 |
if(write_image(filename, out_buffer)) { |
if(write_image(filename, out_buffer)) { |
392 |
fprintf(stderr, |
fprintf(stderr, |
393 |
"Error writing decoded PGM frame %s\n", |
"Error writing decoded frame %s\n", |
394 |
filename); |
filename); |
395 |
} |
} |
396 |
} |
} |
403 |
* Calculate totals and averages for output, print results |
* Calculate totals and averages for output, print results |
404 |
****************************************************************************/ |
****************************************************************************/ |
405 |
|
|
406 |
|
if (filenr>0) { |
407 |
totalsize /= filenr; |
totalsize /= filenr; |
408 |
totaldectime /= filenr; |
totaldectime /= filenr; |
|
|
|
409 |
printf("Avg: dectime(ms) =%7.2f, fps =%7.2f, length(bytes) =%7d\n", |
printf("Avg: dectime(ms) =%7.2f, fps =%7.2f, length(bytes) =%7d\n", |
410 |
totaldectime, 1000/totaldectime, (int)totalsize); |
totaldectime, 1000/totaldectime, (int)totalsize); |
411 |
|
}else{ |
412 |
|
printf("Nothing was decoded!\n"); |
413 |
|
} |
414 |
|
|
415 |
/***************************************************************************** |
/***************************************************************************** |
416 |
* XviD PART Stop |
* XviD PART Stop |
474 |
* output functions |
* output functions |
475 |
****************************************************************************/ |
****************************************************************************/ |
476 |
|
|
477 |
int write_image(char *prefix, unsigned char *image) |
static int write_image(char *prefix, unsigned char *image) |
478 |
{ |
{ |
479 |
char filename[1024]; |
char filename[1024]; |
480 |
char *ext; |
char *ext; |
502 |
return(ret); |
return(ret); |
503 |
} |
} |
504 |
|
|
505 |
int write_tga(char *filename, unsigned char *image) |
static int write_tga(char *filename, unsigned char *image) |
506 |
{ |
{ |
507 |
FILE * f; |
FILE * f; |
508 |
char hdr[18]; |
char hdr[18]; |
583 |
return(0); |
return(0); |
584 |
} |
} |
585 |
|
|
586 |
int write_pnm(char *filename, unsigned char *image) |
static int write_pnm(char *filename, unsigned char *image) |
587 |
{ |
{ |
588 |
FILE * f; |
FILE * f; |
589 |
|
|
622 |
|
|
623 |
return 0; |
return 0; |
624 |
} |
} |
625 |
|
|
626 |
/***************************************************************************** |
/***************************************************************************** |
627 |
* Routines for decoding: init decoder, use, and stop decoder |
* Routines for decoding: init decoder, use, and stop decoder |
628 |
****************************************************************************/ |
****************************************************************************/ |
636 |
xvid_gbl_init_t xvid_gbl_init; |
xvid_gbl_init_t xvid_gbl_init; |
637 |
xvid_dec_create_t xvid_dec_create; |
xvid_dec_create_t xvid_dec_create; |
638 |
|
|
639 |
|
/* Reset the structure with zeros */ |
640 |
|
memset(&xvid_gbl_init, 0, sizeof(xvid_gbl_init_t)); |
641 |
|
memset(&xvid_dec_create, 0, sizeof(xvid_dec_create_t)); |
642 |
|
|
643 |
/*------------------------------------------------------------------------ |
/*------------------------------------------------------------------------ |
644 |
* XviD core initialization |
* XviD core initialization |
645 |
*----------------------------------------------------------------------*/ |
*----------------------------------------------------------------------*/ |