[FFmpeg-devel] qt-faststart not works on 64-bit box
Surf Chen
surfchen
Mon May 19 06:48:56 CEST 2008
The fseeko works incorrectly on 64-bit box.
Below shows what the problem is. If change the fseeko to fseek,all goes well.
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#define ATOM_PREAMBLE_SIZE 8
int main(int argc, char *argv[]) {
unsigned char *ftyp_atom = 0;
unsigned char atom_bytes[ATOM_PREAMBLE_SIZE];
FILE *infile = fopen(argv[1], "rb");
ftyp_atom = malloc(32);
fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile);
fseeko(infile, -ATOM_PREAMBLE_SIZE, SEEK_CUR);
int rs=fread(ftyp_atom, 2, 1, infile);
printf ("rs:%d\n",rs);
return 0;
}
The fseeko is used in qt-faststart.c,cause it not works on 64-bit
box.Here is my patch to work it out.Simply replace fseeko with fseek.
Index: qt-faststart.c
===================================================================
--- qt-faststart.c (revision 13198)
+++ qt-faststart.c (working copy)
@@ -130,7 +130,7 @@
fclose(infile);
return 1;
}
- fseeko(infile, -ATOM_PREAMBLE_SIZE, SEEK_CUR);
+ fseek(infile, -ATOM_PREAMBLE_SIZE, SEEK_CUR);
if (fread(ftyp_atom, atom_size, 1, infile) != 1) {
perror(argv[1]);
free(ftyp_atom);
@@ -147,9 +147,9 @@
break;
}
atom_size = BE_64(&atom_bytes[0]);
- fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE * 2, SEEK_CUR);
+ fseek(infile, atom_size - ATOM_PREAMBLE_SIZE * 2, SEEK_CUR);
} else {
- fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE, SEEK_CUR);
+ fseek(infile, atom_size - ATOM_PREAMBLE_SIZE, SEEK_CUR);
}
}
@@ -161,7 +161,7 @@
/* moov atom was, in fact, the last atom in the chunk; load the whole
* moov atom */
- fseeko(infile, -atom_size, SEEK_END);
+ fseek(infile, -atom_size, SEEK_END);
last_offset = ftello(infile);
moov_atom_size = atom_size;
moov_atom = malloc(moov_atom_size);
More information about the ffmpeg-devel
mailing list