[xiph-commits] r8991 - trunk/theora/win32/experimental/transcoder/avi2vp3

giles at motherfish-iii.xiph.org giles at motherfish-iii.xiph.org
Sat Feb 26 21:07:43 PST 2005


Author: giles
Date: 2005-02-26 21:07:42 -0800 (Sat, 26 Feb 2005)
New Revision: 8991

Modified:
   trunk/theora/win32/experimental/transcoder/avi2vp3/avi2vp3.c
   trunk/theora/win32/experimental/transcoder/avi2vp3/avilib.c
Log:
avi2vp3 cleanup.

open() on win32 requires an O_BINARY flag. If this flag isn't defined by
the os, we define it to 0 so that it has no effect when or'd with the
other flags.

win32 also doesn't define to the mode flags, so fall back to a manual
0644 constant.

AVI_max_video_chunk() returns zero on files without an idx table: fall back
to a 128K buffer in such cases. This is cleaner than the universal 32K buffer
used in the theora-tools version.

Based on a patch from Nehal Mistry.


Modified: trunk/theora/win32/experimental/transcoder/avi2vp3/avi2vp3.c
===================================================================
--- trunk/theora/win32/experimental/transcoder/avi2vp3/avi2vp3.c	2005-02-26 22:11:56 UTC (rev 8990)
+++ trunk/theora/win32/experimental/transcoder/avi2vp3/avi2vp3.c	2005-02-27 05:07:42 UTC (rev 8991)
@@ -20,11 +20,12 @@
     int olength;
     int length;
     avi_t *avifile;
+    int chucksize;    
     int frame;
     int frames;
     int keyframegap = 0;
     int maxkeyframegap = 0;
-    
+
     DWORD initialticks;
     
     int framew = 0;
@@ -37,7 +38,12 @@
     framew = AVI_video_width(avifile);
     frameh = AVI_video_height(avifile);
     framerate = AVI_frame_rate(avifile);
-    buffer = malloc(AVI_max_video_chunk(avifile));
+    chunksize = AVI_max_video_chunk(avifile);
+    /* avilib only reports the max video chunk size if the file has an
+       idx table. We fall back to an arbitrary limit otherwise. Better
+       would be just to handle the chunks dynamically */
+    if (chunksize <= 0) chunksize = 131072;
+    buffer = malloc(chunksize);
     printf("Frames(%d) Video(%dx%d) %3.2f fps\n",frames,framew, frameh,framerate);
     printf("Video Compressor: %s", AVI_video_compressor(avifile));
     fps_denominator = 1000000.0F;

Modified: trunk/theora/win32/experimental/transcoder/avi2vp3/avilib.c
===================================================================
--- trunk/theora/win32/experimental/transcoder/avi2vp3/avilib.c	2005-02-26 22:11:56 UTC (rev 8990)
+++ trunk/theora/win32/experimental/transcoder/avi2vp3/avilib.c	2005-02-27 05:07:42 UTC (rev 8991)
@@ -44,6 +44,12 @@
 #define VERSION "0.00"
 #endif
 
+#ifndef O_BINARY
+/* win32 wants a binary flag to open(); this sets it to null
+   on platforms that don't have it. */
+#define O_BINARY 0
+#endif
+
 /*******************************************************************
  *                                                                 *
  *    Utilities for writing an AVI File                            *
@@ -229,7 +235,7 @@
   /* mask = umask (0);
    umask (mask);*/
 
-   AVI->fdes = open(filename, O_RDWR|O_CREAT, (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) &~ mask);
+   AVI->fdes = open(filename, O_RDWR|O_CREAT|O_BINARY, 0644 &~ mask);
    if (AVI->fdes < 0)
    {
       AVI_errno = AVI_ERR_OPEN;
@@ -1076,7 +1082,7 @@
   
   /* Open the file */
   
-  AVI->fdes = open(filename,O_RDONLY);
+  AVI->fdes = open(filename,O_RDONLY|O_BINARY);
   if(AVI->fdes < 0)
     {
       AVI_errno = AVI_ERR_OPEN;



More information about the commits mailing list