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.13 2004-04-13 21:20:45 suxen_drol 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_tga(char *filename, unsigned char *image); |
91 |
|
static int write_pnm(char *filename, unsigned char *image); |
92 |
|
|
93 |
|
|
94 |
const char * type2str(int type) |
const char * type2str(int type) |
185 |
} |
} |
186 |
} |
} |
187 |
|
|
188 |
|
#if defined(_MSC_VER) |
189 |
|
if (ARG_INPUTFILE==NULL) { |
190 |
|
fprintf(stderr, "Warning: MSVC build does not read correctly from stdin. Use the -i switch.\n\n"); |
191 |
|
} |
192 |
|
#endif |
193 |
|
|
194 |
/***************************************************************************** |
/***************************************************************************** |
195 |
* Values checking |
* Values checking |
196 |
****************************************************************************/ |
****************************************************************************/ |
350 |
sprintf(filename, "%sdec%05d", filepath, filenr); |
sprintf(filename, "%sdec%05d", filepath, filenr); |
351 |
if(write_image(filename, out_buffer)) { |
if(write_image(filename, out_buffer)) { |
352 |
fprintf(stderr, |
fprintf(stderr, |
353 |
"Error writing decoded PGM frame %s\n", |
"Error writing decoded frame %s\n", |
354 |
filename); |
filename); |
355 |
} |
} |
356 |
} |
} |
391 |
sprintf(filename, "%sdec%05d", filepath, filenr); |
sprintf(filename, "%sdec%05d", filepath, filenr); |
392 |
if(write_image(filename, out_buffer)) { |
if(write_image(filename, out_buffer)) { |
393 |
fprintf(stderr, |
fprintf(stderr, |
394 |
"Error writing decoded PGM frame %s\n", |
"Error writing decoded frame %s\n", |
395 |
filename); |
filename); |
396 |
} |
} |
397 |
} |
} |
404 |
* Calculate totals and averages for output, print results |
* Calculate totals and averages for output, print results |
405 |
****************************************************************************/ |
****************************************************************************/ |
406 |
|
|
407 |
|
if (filenr>0) { |
408 |
totalsize /= filenr; |
totalsize /= filenr; |
409 |
totaldectime /= filenr; |
totaldectime /= filenr; |
|
|
|
410 |
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", |
411 |
totaldectime, 1000/totaldectime, (int)totalsize); |
totaldectime, 1000/totaldectime, (int)totalsize); |
412 |
|
}else{ |
413 |
|
printf("Nothing was decoded!\n"); |
414 |
|
} |
415 |
|
|
416 |
|
|
417 |
/***************************************************************************** |
/***************************************************************************** |
418 |
* XviD PART Stop |
* XviD PART Stop |
476 |
* output functions |
* output functions |
477 |
****************************************************************************/ |
****************************************************************************/ |
478 |
|
|
479 |
int write_image(char *prefix, unsigned char *image) |
static int write_image(char *prefix, unsigned char *image) |
480 |
{ |
{ |
481 |
char filename[1024]; |
char filename[1024]; |
482 |
char *ext; |
char *ext; |
504 |
return(ret); |
return(ret); |
505 |
} |
} |
506 |
|
|
507 |
int write_tga(char *filename, unsigned char *image) |
static int write_tga(char *filename, unsigned char *image) |
508 |
{ |
{ |
509 |
FILE * f; |
FILE * f; |
510 |
char hdr[18]; |
char hdr[18]; |