[Ffmpeg-cvslog] CVS: ffmpeg cws2fws.c,1.3,1.4

Alex Beregszaszi alex
Sun Jan 15 02:19:05 CET 2006


Update of /cvsroot/ffmpeg/ffmpeg
In directory mail:/var2/tmp/cvs-serv18419

Modified Files:
	cws2fws.c 
Log Message:
10l: now it works really, with 1k outbut buffers it failed more times, with 65k it looks safe with all samples i had

Index: cws2fws.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/cws2fws.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cws2fws.c	22 Dec 2005 01:10:05 -0000	1.3
+++ cws2fws.c	15 Jan 2006 01:19:02 -0000	1.4
@@ -19,7 +19,7 @@
 main(int argc, char *argv[])
 {
     int fd_in, fd_out, comp_len, uncomp_len, tag, i, last_out;
-    char buf_in[1024], buf_out[1024];
+    char buf_in[1024], buf_out[65536];
     z_stream zstream;
     struct stat statbuf;
 
@@ -73,7 +73,7 @@
     zstream.opaque = NULL;
     inflateInit(&zstream);
 
-    for (i = 0; i < comp_len-4;)
+    for (i = 0; i < comp_len-8;)
     {
         int ret, len = read(fd_in, &buf_in, 1024);
 
@@ -84,12 +84,10 @@
         zstream.next_in = &buf_in[0];
         zstream.avail_in = len;
         zstream.next_out = &buf_out[0];
-        zstream.avail_out = 1024;
+        zstream.avail_out = 65536;
 
         ret = inflate(&zstream, Z_SYNC_FLUSH);
-        if (ret == Z_STREAM_END || ret == Z_BUF_ERROR)
-            break;
-        if (ret != Z_OK)
+        if (ret != Z_STREAM_END && ret != Z_OK)
         {
             printf("Error while decompressing: %d\n", ret);
             inflateEnd(&zstream);
@@ -103,6 +101,9 @@
         write(fd_out, &buf_out, zstream.total_out-last_out);
 
         i += len;
+
+        if (ret == Z_STREAM_END || ret == Z_BUF_ERROR)
+            break;
     }
 
     if (zstream.total_out != uncomp_len-8)





More information about the ffmpeg-cvslog mailing list