[xiph-commits] r8992 - trunk/theora-tools/theora_transcoder
giles at motherfish-iii.xiph.org
giles at motherfish-iii.xiph.org
Sat Feb 26 22:50:26 PST 2005
Author: giles
Date: 2005-02-26 22:50:25 -0800 (Sat, 26 Feb 2005)
New Revision: 8992
Modified:
trunk/theora-tools/theora_transcoder/avi2vp3.c
trunk/theora-tools/theora_transcoder/avilib.c
Log:
avi2vp3 cleanup propagated from the win32/experimental code in the theora
tree.
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-tools/theora_transcoder/avi2vp3.c
===================================================================
--- trunk/theora-tools/theora_transcoder/avi2vp3.c 2005-02-27 05:07:42 UTC (rev 8991)
+++ trunk/theora-tools/theora_transcoder/avi2vp3.c 2005-02-27 06:50:25 UTC (rev 8992)
@@ -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;
@@ -33,11 +34,16 @@
double fps_numerator, fps_denominator;
avifile = AVI_open_input_file("vp31.avi", 1);
- buffer = malloc(AVI_max_video_chunk(avifile));
frames = AVI_video_frames(avifile);
framew = AVI_video_width(avifile);
frameh = AVI_video_height(avifile);
framerate = AVI_frame_rate(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-tools/theora_transcoder/avilib.c
===================================================================
--- trunk/theora-tools/theora_transcoder/avilib.c 2005-02-27 05:07:42 UTC (rev 8991)
+++ trunk/theora-tools/theora_transcoder/avilib.c 2005-02-27 06:50:25 UTC (rev 8992)
@@ -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