Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
flac
Commits
29c47977
Commit
29c47977
authored
Jan 11, 2003
by
Josh Coalson
Browse files
fix bug when reading very small raw files
parent
fb48f24b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/flac/encode.c
View file @
29c47977
...
...
@@ -1055,21 +1055,27 @@ int flac__encode_raw(FILE *infile, long infilesize, const char *infilename, cons
const
FLAC__uint64
max_input_bytes
=
encoder_session
.
total_samples_to_encode
*
bytes_per_wide_sample
;
FLAC__uint64
total_input_bytes_read
=
0
;
while
(
total_input_bytes_read
<
max_input_bytes
)
{
size_t
wanted
=
(
CHUNK_OF_SAMPLES
*
bytes_per_wide_sample
);
wanted
=
min
(
wanted
,
(
size_t
)(
max_input_bytes
-
total_input_bytes_read
));
if
(
lookahead_length
>
0
)
{
FLAC__ASSERT
(
lookahead_length
<
wanted
);
memcpy
(
ucbuffer_
,
lookahead
,
lookahead_length
);
bytes_read
=
fread
(
ucbuffer_
+
lookahead_length
,
sizeof
(
unsigned
char
),
wanted
-
lookahead_length
,
infile
)
+
lookahead_length
;
if
(
ferror
(
infile
))
{
fprintf
(
stderr
,
"%s: ERROR during read
\n
"
,
encoder_session
.
inbasefilename
);
return
EncoderSession_finish_error
(
&
encoder_session
);
{
size_t
wanted
=
(
CHUNK_OF_SAMPLES
*
bytes_per_wide_sample
);
wanted
=
min
(
wanted
,
(
size_t
)(
max_input_bytes
-
total_input_bytes_read
));
if
(
lookahead_length
>
0
)
{
FLAC__ASSERT
(
lookahead_length
<=
wanted
);
memcpy
(
ucbuffer_
,
lookahead
,
lookahead_length
);
wanted
-=
lookahead_length
;
bytes_read
=
lookahead_length
;
if
(
wanted
>
0
)
{
bytes_read
+=
fread
(
ucbuffer_
+
lookahead_length
,
sizeof
(
unsigned
char
),
wanted
,
infile
);
if
(
ferror
(
infile
))
{
fprintf
(
stderr
,
"%s: ERROR during read
\n
"
,
encoder_session
.
inbasefilename
);
return
EncoderSession_finish_error
(
&
encoder_session
);
}
}
lookahead_length
=
0
;
}
lookahead_length
=
0
;
else
bytes_read
=
fread
(
ucbuffer_
,
sizeof
(
unsigned
char
),
wanted
,
infile
);
}
else
bytes_read
=
fread
(
ucbuffer_
,
sizeof
(
unsigned
char
),
wanted
,
infile
);
if
(
bytes_read
==
0
)
{
if
(
ferror
(
infile
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment