[svn] / trunk / xvidcore / examples / xvid_decraw.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/examples/xvid_decraw.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1879, Tue Nov 10 14:06:58 2009 UTC revision 1880, Tue Jan 5 09:25:19 2010 UTC
# Line 20  Line 20 
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.24 2006-02-15 19:16:39 Isibaar Exp $   * $Id: xvid_decraw.c,v 1.25 2010-01-05 09:25:19 Isibaar Exp $
24   *   *
25   ****************************************************************************/   ****************************************************************************/
26    
# Line 56  Line 56 
56    
57  #define USE_PNM 0  #define USE_PNM 0
58  #define USE_TGA 1  #define USE_TGA 1
59    #define USE_YUV 2
60    
61  static int XDIM = 0;  static int XDIM = 0;
62  static int YDIM = 0;  static int YDIM = 0;
# Line 90  Line 91 
91  static int write_image(char *prefix, unsigned char *image);  static int write_image(char *prefix, unsigned char *image);
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);
95    
96  const char * type2str(int type)  const char * type2str(int type)
97  {  {
# Line 174  Line 176 
176                          i++;                          i++;
177                          if (strcmp(argv[i], "tga") == 0) {                          if (strcmp(argv[i], "tga") == 0) {
178                                  FORMAT = USE_TGA;                                  FORMAT = USE_TGA;
179                            } else if (strcmp(argv[i], "yuv") == 0) {
180                                    FORMAT = USE_YUV;
181                          } else {                          } else {
182                                  FORMAT = USE_PNM;                                  FORMAT = USE_PNM;
183                          }                          }
# Line 212  Line 216 
216          if (BPP != 1 && BPP != 3 && FORMAT == USE_PNM) {          if (BPP != 1 && BPP != 3 && FORMAT == USE_PNM) {
217                  FORMAT = USE_TGA;                  FORMAT = USE_TGA;
218          }          }
219            if (BPP != 1 && FORMAT == USE_YUV) {
220                    FORMAT = USE_TGA;
221            }
222    
223  /*****************************************************************************  /*****************************************************************************
224   *        Memory allocation   *        Memory allocation
# Line 368  Line 375 
375    
376                  /* Save output frame if required */                  /* Save output frame if required */
377                  if (ARG_SAVEDECOUTPUT) {                  if (ARG_SAVEDECOUTPUT) {
378                            if (FORMAT == USE_YUV) {
379                                    sprintf(filename, "%sdec", filepath);
380                            }
381                            else {
382                          sprintf(filename, "%sdec%05d", filepath, filenr);                          sprintf(filename, "%sdec%05d", filepath, filenr);
383                            }
384                          if(write_image(filename, out_buffer)) {                          if(write_image(filename, out_buffer)) {
385                                  fprintf(stderr,                                  fprintf(stderr,
386                                                  "Error writing decoded frame %s\n",                                                  "Error writing decoded frame %s\n",
# Line 416  Line 428 
428    
429                  /* Save output frame if required */                  /* Save output frame if required */
430                  if (ARG_SAVEDECOUTPUT) {                  if (ARG_SAVEDECOUTPUT) {
431                            if (FORMAT == USE_YUV) {
432                                    sprintf(filename, "%sdec", filepath);
433                            }
434                            else {
435                          sprintf(filename, "%sdec%05d", filepath, filenr);                          sprintf(filename, "%sdec%05d", filepath, filenr);
436                            }
437                          if(write_image(filename, out_buffer)) {                          if(write_image(filename, out_buffer)) {
438                                  fprintf(stderr,                                  fprintf(stderr,
439                                                  "Error writing decoded frame %s\n",                                                  "Error writing decoded frame %s\n",
# Line 473  Line 490 
490          fprintf(stderr, " -i string      : input filename (default=stdin)\n");          fprintf(stderr, " -i string      : input filename (default=stdin)\n");
491          fprintf(stderr, " -d             : save decoder output\n");          fprintf(stderr, " -d             : save decoder output\n");
492          fprintf(stderr, " -c csp         : choose colorspace output (rgb16, rgb24, rgb32, yv12, i420)\n");          fprintf(stderr, " -c csp         : choose colorspace output (rgb16, rgb24, rgb32, yv12, i420)\n");
493          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");
494          fprintf(stderr, " -m             : save mpeg4 raw stream to individual files\n");          fprintf(stderr, " -m             : save mpeg4 raw stream to individual files\n");
495          fprintf(stderr, " -help          : This help message\n");          fprintf(stderr, " -help          : This help message\n");
496          fprintf(stderr, " (* means default)\n");          fprintf(stderr, " (* means default)\n");
# Line 513  Line 530 
530                  ext = "pgm";                  ext = "pgm";
531          } else if (FORMAT == USE_PNM && BPP == 3) {          } else if (FORMAT == USE_PNM && BPP == 3) {
532                  ext = "pnm";                  ext = "pnm";
533            } else if (FORMAT == USE_YUV) {
534                    ext = "yuv";
535          } else if (FORMAT == USE_TGA) {          } else if (FORMAT == USE_TGA) {
536                  ext = "tga";                  ext = "tga";
537          } else {          } else {
# Line 524  Line 543 
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) {
547                    ret = write_yuv(filename, image);
548          } else {          } else {
549                  ret = write_tga(filename, image);                  ret = write_tga(filename, image);
550          }          }
# Line 652  Line 673 
673          return 0;          return 0;
674  }  }
675    
676    static int write_yuv(char *filename, unsigned char *image)
677    {
678            FILE * f;
679    
680            f = fopen(filename, "ab+");
681            if ( f == NULL) {
682                    return -1;
683            }
684    
685            if (BPP == 1) {
686                    int i;
687    
688                    fwrite(image, 1, XDIM*YDIM, f);
689    
690                    for (i=0; i<YDIM/2;i++) {
691                            fwrite(image+XDIM*YDIM + i*XDIM/2, 1, XDIM/2, f);
692                            fwrite(image+5*XDIM*YDIM/4 + i*XDIM/2, 1, XDIM/2, f);
693                    }
694            }
695    
696            fclose(f);
697    
698            return 0;
699    }
700    
701  /*****************************************************************************  /*****************************************************************************
702   * Routines for decoding: init decoder, use, and stop decoder   * Routines for decoding: init decoder, use, and stop decoder
703   ****************************************************************************/   ****************************************************************************/

Legend:
Removed from v.1879  
changed lines
  Added in v.1880

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