88 |
xvid_dec_stats_t *xvid_dec_stats); |
xvid_dec_stats_t *xvid_dec_stats); |
89 |
static int dec_stop(); |
static int dec_stop(); |
90 |
static void usage(); |
static void usage(); |
91 |
static int write_image(char *prefix, unsigned char *image); |
static int write_image(char *prefix, unsigned char *image, int filenr); |
92 |
static int write_pnm(char *filename, unsigned char *image); |
static int write_pnm(char *filename, unsigned char *image); |
93 |
static int write_tga(char *filename, unsigned char *image); |
static int write_tga(char *filename, unsigned char *image); |
94 |
static int write_yuv(char *filename, unsigned char *image); |
static int write_yuv(char *filename, unsigned char *image); |
375 |
|
|
376 |
/* Save output frame if required */ |
/* Save output frame if required */ |
377 |
if (ARG_SAVEDECOUTPUT) { |
if (ARG_SAVEDECOUTPUT) { |
|
if (FORMAT == USE_YUV) { |
|
378 |
sprintf(filename, "%sdec", filepath); |
sprintf(filename, "%sdec", filepath); |
379 |
} |
|
380 |
else { |
if(write_image(filename, out_buffer, filenr)) { |
|
sprintf(filename, "%sdec%05d", filepath, filenr); |
|
|
} |
|
|
if(write_image(filename, out_buffer)) { |
|
381 |
fprintf(stderr, |
fprintf(stderr, |
382 |
"Error writing decoded frame %s\n", |
"Error writing decoded frame %s\n", |
383 |
filename); |
filename); |
424 |
|
|
425 |
/* Save output frame if required */ |
/* Save output frame if required */ |
426 |
if (ARG_SAVEDECOUTPUT) { |
if (ARG_SAVEDECOUTPUT) { |
|
if (FORMAT == USE_YUV) { |
|
427 |
sprintf(filename, "%sdec", filepath); |
sprintf(filename, "%sdec", filepath); |
428 |
} |
|
429 |
else { |
if(write_image(filename, out_buffer, filenr)) { |
|
sprintf(filename, "%sdec%05d", filepath, filenr); |
|
|
} |
|
|
if(write_image(filename, out_buffer)) { |
|
430 |
fprintf(stderr, |
fprintf(stderr, |
431 |
"Error writing decoded frame %s\n", |
"Error writing decoded frame %s\n", |
432 |
filename); |
filename); |
512 |
* output functions |
* output functions |
513 |
****************************************************************************/ |
****************************************************************************/ |
514 |
|
|
515 |
static int write_image(char *prefix, unsigned char *image) |
static int write_image(char *prefix, unsigned char *image, int filenr) |
516 |
{ |
{ |
517 |
char filename[1024]; |
char filename[1024]; |
518 |
char *ext; |
char *ext; |
531 |
exit(-1); |
exit(-1); |
532 |
} |
} |
533 |
|
|
534 |
|
if (FORMAT == USE_YUV) { |
535 |
sprintf(filename, "%s.%s", prefix, ext); |
sprintf(filename, "%s.%s", prefix, ext); |
536 |
|
|
537 |
|
if (!filenr) { |
538 |
|
FILE *fp = fopen(filename, "wb"); |
539 |
|
fclose(fp); |
540 |
|
} |
541 |
|
} else |
542 |
|
sprintf(filename, "%s%05d.%s", prefix, filenr, ext); |
543 |
|
|
544 |
if (FORMAT == USE_PNM) { |
if (FORMAT == USE_PNM) { |
545 |
ret = write_pnm(filename, image); |
ret = write_pnm(filename, image); |
546 |
} else if (FORMAT == USE_YUV) { |
} else if (FORMAT == USE_YUV) { |
682 |
return -1; |
return -1; |
683 |
} |
} |
684 |
|
|
685 |
if (BPP == 1) { |
fwrite(image, 1, 3*XDIM*YDIM/2, f); |
|
int i; |
|
|
|
|
|
fwrite(image, 1, XDIM*YDIM, f); |
|
|
|
|
|
for (i=0; i<YDIM/2;i++) { |
|
|
fwrite(image+XDIM*YDIM + i*XDIM/2, 1, XDIM/2, f); |
|
|
fwrite(image+5*XDIM*YDIM/4 + i*XDIM/2, 1, XDIM/2, f); |
|
|
} |
|
|
} |
|
686 |
|
|
687 |
fclose(f); |
fclose(f); |
688 |
|
|