[FFmpeg-devel] [PATCH] tools/cws2fws.c tweaks
Måns Rullgård
mans
Wed Aug 25 01:38:04 CEST 2010
James Darnley <james.darnley at gmail.com> writes:
> Is this tool still supported?
>
> I was trying to use this tool on Windows but it repeatedly failed. I
> discovered this was because it doesn't open the file in binary mode.
> A simple binary or with O_BINARY solved that.
>
> Then I saw that it was not interpreting the size correctly, reading
> the input as signed chars. It managed to interpret hex(46 BD 0B 00)
> as -17086. Changing them to unsigned chars fixed that.
>
> I've attached a diff which has these changes.
>
> diff --git a/tools/cws2fws.c b/tools/cws2fws.c
> index aa7d690..4b9daeb 100644
> --- a/tools/cws2fws.c
> +++ b/tools/cws2fws.c
> @@ -22,7 +22,7 @@
> int main(int argc, char *argv[])
> {
> int fd_in, fd_out, comp_len, uncomp_len, i, last_out;
> - char buf_in[1024], buf_out[65536];
> + unsigned char buf_in[1024], buf_out[65536];
> z_stream zstream;
> struct stat statbuf;
uint8_t
> @@ -32,14 +32,14 @@ int main(int argc, char *argv[])
> exit(1);
> }
>
> - fd_in = open(argv[1], O_RDONLY);
> + fd_in = open(argv[1], O_RDONLY|O_BINARY);
> if (fd_in < 0)
> {
> perror("Error while opening: ");
> exit(1);
> }
>
> - fd_out = open(argv[2], O_WRONLY|O_CREAT, 00644);
> + fd_out = open(argv[2], O_WRONLY|O_CREAT|O_BINARY, 00644);
> if (fd_out < 0)
> {
> perror("Error while opening: ");
This will break on anything without O_BINARY defined, which is most
sane systems.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list