[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 1547, Sat Sep 4 14:16:24 2004 UTC revision 1678, Wed Feb 15 19:16:39 2006 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.19 2004-09-04 14:16:24 edgomez Exp $   * $Id: xvid_decraw.c,v 1.24 2006-02-15 19:16:39 Isibaar Exp $
24   *   *
25   ****************************************************************************/   ****************************************************************************/
26    
# Line 73  Line 73 
73    
74  static const int display_buffer_bytes = 0;  static const int display_buffer_bytes = 0;
75    
76    #define MIN_USEFUL_BYTES 1
77    
78  /*****************************************************************************  /*****************************************************************************
79   *               Local prototypes   *               Local prototypes
80   ****************************************************************************/   ****************************************************************************/
# Line 265  Line 267 
267                          mp4_ptr = mp4_buffer;                          mp4_ptr = mp4_buffer;
268    
269                          /* read new data */                          /* read new data */
270              if(feof(in_file))              if(!feof(in_file)) {
                                 break;  
   
271                          useful_bytes += fread(mp4_buffer + already_in_buffer,                          useful_bytes += fread(mp4_buffer + already_in_buffer,
272                                                                    1, BUFFER_SIZE - already_in_buffer,                                                                    1, BUFFER_SIZE - already_in_buffer,
273                                                                    in_file);                                                                    in_file);
274                            }
275                  }                  }
276    
277    
# Line 333  Line 333 
333                          if (display_buffer_bytes) {                          if (display_buffer_bytes) {
334                                  printf("Data chunk %d: %d bytes consumed, %d bytes in buffer\n", chunk++, used_bytes, useful_bytes);                                  printf("Data chunk %d: %d bytes consumed, %d bytes in buffer\n", chunk++, used_bytes, useful_bytes);
335                          }                          }
336                  } while (xvid_dec_stats.type <= 0 && useful_bytes > 0);                  } while (xvid_dec_stats.type <= 0 && useful_bytes > MIN_USEFUL_BYTES);
337    
338                  /* Check if there is a negative number of useful bytes left in buffer                  /* Check if there is a negative number of useful bytes left in buffer
339                   * This means we went too far */                   * This means we went too far */
# Line 378  Line 378 
378    
379                  filenr++;                  filenr++;
380    
381          } while (useful_bytes>0 || !feof(in_file));          } while (useful_bytes>MIN_USEFUL_BYTES || !feof(in_file));
382    
383          useful_bytes = 0; /* Empty buffer */          useful_bytes = 0; /* Empty buffer */
384    
# Line 495  Line 495 
495  #else  #else
496          clock_t clk;          clock_t clk;
497          clk = clock();          clk = clock();
498          return(clk * 1000 / CLOCKS_PER_SEC);          return(clk * 1000.0 / CLOCKS_PER_SEC);
499  #endif  #endif
500  }  }
501    
# Line 574  Line 574 
574  #else  #else
575          {          {
576                  int i;                  int i;
577                  for (i=0; i<width*height*BPP;i+=BPP) {                  for (i=0; i<XDIM*YDIM*BPP;i+=BPP) {
578                          if (BPP == 1) {                          if (BPP == 1) {
579                                  fputc(image+i, f);                                  fputc(*(image+i), f);
580                          } else if (BPP == 2) {                          } else if (BPP == 2) {
581                                  fputc(image+i+1, f);                                  fputc(*(image+i+1), f);
582                                  fputc(image+i+0, f);                                  fputc(*(image+i+0), f);
583                          } else if (BPP == 3) {                          } else if (BPP == 3) {
584                                  fputc(image+i+2, f);                                  fputc(*(image+i+2), f);
585                                  fputc(image+i+1, f);                                  fputc(*(image+i+1), f);
586                                  fputc(image+i+0, f);                                  fputc(*(image+i+0), f);
587                          } else if (BPP == 4) {                          } else if (BPP == 4) {
588                                  fputc(image+i+3, f);                                  fputc(*(image+i+3), f);
589                                  fputc(image+i+2, f);                                  fputc(*(image+i+2), f);
590                                  fputc(image+i+1, f);                                  fputc(*(image+i+1), f);
591                                  fputc(image+i+0, f);                                  fputc(*(image+i+0), f);
592                          }                          }
593                  }                  }
594          }          }
# Line 623  Line 623 
623    
624          if (BPP == 1) {          if (BPP == 1) {
625                  int i;                  int i;
626                  fprintf(f, "P5\n#xvid\n%i %i\n255\n", XDIM, YDIM*3/2);                  fprintf(f, "P5\n%i %i\n255\n", XDIM, YDIM*3/2);
627    
628                  fwrite(image, 1, XDIM*YDIM, f);                  fwrite(image, 1, XDIM*YDIM, f);
629    

Legend:
Removed from v.1547  
changed lines
  Added in v.1678

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