[XviD-devel] Fw: libxvidcore decompression

Dark Sylinc dark_sylinc at yahoo.com.ar
Wed Apr 16 17:50:19 CEST 2008


> 2. determine the buffer size to allocate for the
> read stream buffer through
>     fseek(fpi,0,SEEK_END);
>     long lFileSize = ftell(fpi);
>     unsigned char *buffer = NULL;
>     buffer = (unsigned char *) malloc (lFileSize);
>     int useful_bytes = fread(buffer, 1, lFileSize,
> fpi);
>     if(useful_bytes==NULL)
>           Msg(TEXT("Errorreading to file"));
> 

You're missing a call. Everything else seems fine.
You're going to the end of the file with
"fseek(fpi,0,SEEK_END);" to guess the filesize.
However, you don't rewind it. There is a specific
function called something like rewind(fpi), but using 
"fseek(fpi,0,SEEK_SET);" will do it.

Your code should look like this:
>     fseek(fpi,0,SEEK_END);
>     long lFileSize = ftell(fpi);
     fseek(fpi,0,SEEK_SET);  //<---Note here!
(anywhere before calling fread)
>     unsigned char *buffer = NULL;
>     buffer = (unsigned char *) malloc (lFileSize);
>     int useful_bytes = fread(buffer, 1, lFileSize,
> fpi);
>     if(useful_bytes==NULL)
>           Msg(TEXT("Errorreading to file"));


Cheers
Dark Sylinc

IMPORTANT:
The information contained in this email may be commercially sensitive and/or legally privileged. It is intended solely for the person(s) to whom it is addressed. If the reader of this message is not the intended recipient, you are on notice of its status and hereby notified that your access is unauthorized, and any review, dissemination, distribution, disclose or copying of this message including any attachments is strictly prohibited. Please notify the sender immediately by reply e-mail and then delete this message from your system.


      Tarjeta de crédito Yahoo! de Banco Supervielle.
Solicitá tu nueva Tarjeta de crédito. De tu PC directo a tu casa. www.tuprimeratarjeta.com.ar 


More information about the XviD-devel mailing list