--- xvid_decraw.c 2005/08/01 10:53:46 1.20 +++ xvid_decraw.c 2006/02/15 19:16:39 1.24 @@ -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.20 2005/08/01 10:53:46 Isibaar Exp $ + * $Id: xvid_decraw.c,v 1.24 2006/02/15 19:16:39 Isibaar Exp $ * ****************************************************************************/ @@ -73,6 +73,8 @@ static const int display_buffer_bytes = 0; +#define MIN_USEFUL_BYTES 1 + /***************************************************************************** * Local prototypes ****************************************************************************/ @@ -265,13 +267,11 @@ mp4_ptr = mp4_buffer; /* read new data */ - if(feof(in_file)) - break; - - useful_bytes += fread(mp4_buffer + already_in_buffer, - 1, BUFFER_SIZE - already_in_buffer, - in_file); - + if(!feof(in_file)) { + useful_bytes += fread(mp4_buffer + already_in_buffer, + 1, BUFFER_SIZE - already_in_buffer, + in_file); + } } @@ -333,7 +333,7 @@ if (display_buffer_bytes) { printf("Data chunk %d: %d bytes consumed, %d bytes in buffer\n", chunk++, used_bytes, useful_bytes); } - } while (xvid_dec_stats.type <= 0 && useful_bytes > 0); + } while (xvid_dec_stats.type <= 0 && useful_bytes > MIN_USEFUL_BYTES); /* Check if there is a negative number of useful bytes left in buffer * This means we went too far */ @@ -378,7 +378,7 @@ filenr++; - } while (useful_bytes>0 || !feof(in_file)); + } while (useful_bytes>MIN_USEFUL_BYTES || !feof(in_file)); useful_bytes = 0; /* Empty buffer */ @@ -495,7 +495,7 @@ #else clock_t clk; clk = clock(); - return(clk * 1000 / CLOCKS_PER_SEC); + return(clk * 1000.0 / CLOCKS_PER_SEC); #endif } @@ -623,7 +623,7 @@ if (BPP == 1) { int i; - 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); fwrite(image, 1, XDIM*YDIM, f);