--- trunk/xvidcore/examples/xvid_decraw.c 2009/11/10 14:06:58 1879 +++ trunk/xvidcore/examples/xvid_decraw.c 2010/01/05 09:25:19 1880 @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: xvid_decraw.c,v 1.24 2006-02-15 19:16:39 Isibaar Exp $ + * $Id: xvid_decraw.c,v 1.25 2010-01-05 09:25:19 Isibaar Exp $ * ****************************************************************************/ @@ -56,6 +56,7 @@ #define USE_PNM 0 #define USE_TGA 1 +#define USE_YUV 2 static int XDIM = 0; static int YDIM = 0; @@ -90,6 +91,7 @@ static int write_image(char *prefix, unsigned char *image); static int write_pnm(char *filename, unsigned char *image); static int write_tga(char *filename, unsigned char *image); +static int write_yuv(char *filename, unsigned char *image); const char * type2str(int type) { @@ -174,6 +176,8 @@ i++; if (strcmp(argv[i], "tga") == 0) { FORMAT = USE_TGA; + } else if (strcmp(argv[i], "yuv") == 0) { + FORMAT = USE_YUV; } else { FORMAT = USE_PNM; } @@ -212,6 +216,9 @@ if (BPP != 1 && BPP != 3 && FORMAT == USE_PNM) { FORMAT = USE_TGA; } + if (BPP != 1 && FORMAT == USE_YUV) { + FORMAT = USE_TGA; + } /***************************************************************************** * Memory allocation @@ -368,7 +375,12 @@ /* Save output frame if required */ if (ARG_SAVEDECOUTPUT) { - sprintf(filename, "%sdec%05d", filepath, filenr); + if (FORMAT == USE_YUV) { + sprintf(filename, "%sdec", filepath); + } + else { + sprintf(filename, "%sdec%05d", filepath, filenr); + } if(write_image(filename, out_buffer)) { fprintf(stderr, "Error writing decoded frame %s\n", @@ -416,7 +428,12 @@ /* Save output frame if required */ if (ARG_SAVEDECOUTPUT) { - sprintf(filename, "%sdec%05d", filepath, filenr); + if (FORMAT == USE_YUV) { + sprintf(filename, "%sdec", filepath); + } + else { + sprintf(filename, "%sdec%05d", filepath, filenr); + } if(write_image(filename, out_buffer)) { fprintf(stderr, "Error writing decoded frame %s\n", @@ -473,7 +490,7 @@ fprintf(stderr, " -i string : input filename (default=stdin)\n"); fprintf(stderr, " -d : save decoder output\n"); fprintf(stderr, " -c csp : choose colorspace output (rgb16, rgb24, rgb32, yv12, i420)\n"); - fprintf(stderr, " -f format : choose output file format (tga, pnm, pgm)\n"); + fprintf(stderr, " -f format : choose output file format (tga, pnm, pgm, yuv)\n"); fprintf(stderr, " -m : save mpeg4 raw stream to individual files\n"); fprintf(stderr, " -help : This help message\n"); fprintf(stderr, " (* means default)\n"); @@ -513,6 +530,8 @@ ext = "pgm"; } else if (FORMAT == USE_PNM && BPP == 3) { ext = "pnm"; + } else if (FORMAT == USE_YUV) { + ext = "yuv"; } else if (FORMAT == USE_TGA) { ext = "tga"; } else { @@ -524,6 +543,8 @@ if (FORMAT == USE_PNM) { ret = write_pnm(filename, image); + } else if (FORMAT == USE_YUV) { + ret = write_yuv(filename, image); } else { ret = write_tga(filename, image); } @@ -652,6 +673,31 @@ return 0; } +static int write_yuv(char *filename, unsigned char *image) +{ + FILE * f; + + f = fopen(filename, "ab+"); + if ( f == NULL) { + return -1; + } + + if (BPP == 1) { + int i; + + fwrite(image, 1, XDIM*YDIM, f); + + for (i=0; i