[Theora-dev] Fix for Theora example encoder
Aaron Colwell
acolwell at real.com
Wed Oct 27 10:02:50 PDT 2004
Here is a patch that prevents the example encoder from rejecting some wav
files that ffmpeg generates. The problem was that it wasn't properly handling
the case where extra bytes were added to the header and they weren't a multiple
of 4 bytes. This fixes that problem by getting the number of extra bytes in the
header and reading that much data.
Aaron
Index: encoder_example.c
===================================================================
--- encoder_example.c (revision 8113)
+++ encoder_example.c (working copy)
@@ -133,6 +133,7 @@
unsigned char buffer[80];
int ret;
int tmp_video_hzn, tmp_video_hzd, tmp_video_an, tmp_video_ad;
+ int extra_hdr_bytes;
/* open it, look for magic */
@@ -179,6 +180,9 @@
ret=fread(buffer,1,20,test);
if(ret<20)goto riff_err;
+ extra_hdr_bytes = (buffer[0] + (buffer[1] << 8) +
+ (buffer[2] << 16) + (buffer[3] << 24)) - 16;
+
if(memcmp(buffer+4,"\001\000",2)){
fprintf(stderr,"The WAV file %s is in a compressed format; "
"can't read it.\n",f);
@@ -195,6 +199,17 @@
exit(1);
}
+ /* read past extra header bytes */
+ while(extra_hdr_bytes){
+ int read_size = (extra_hdr_bytes > sizeof(buffer)) ? sizeof(buffer) : extra_hdr_bytes;
+ ret = fread(buffer, 1, read_size, test);
+
+ if (ret < read_size)
+ goto riff_err;
+ else
+ extra_hdr_bytes -= read_size;
+ }
+
/* Now, align things to the beginning of the data */
/* Look for 'dataxxxx' */
while(!feof(test)){
More information about the Theora-dev
mailing list