mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
Change analyse function to support >4Gbit frames
Theoretically, when a rice parameter of 0, 24-bit samples, fixed predictor with order 0, no rice escaping and a blocksize of 65536 is chosen, a subframe could be up to 2^24*65536 = 1 terabyte in size. While this obviously should never happen, the analyse function should be able to debug such a case.
This commit is contained in:
committed by
Erik de Castro Lopo
parent
5f5035d209
commit
38b7fec143
@@ -62,7 +62,7 @@ void flac__analyze_init(analysis_options aopts)
|
||||
}
|
||||
}
|
||||
|
||||
void flac__analyze_frame(const FLAC__Frame *frame, uint32_t frame_number, FLAC__uint64 frame_offset, uint32_t frame_bytes, analysis_options aopts, FILE *fout)
|
||||
void flac__analyze_frame(const FLAC__Frame *frame, uint32_t frame_number, FLAC__uint64 frame_offset, FLAC__uint64 frame_bytes, analysis_options aopts, FILE *fout)
|
||||
{
|
||||
const uint32_t channels = frame->header.channels;
|
||||
char outfilename[1024];
|
||||
@@ -70,7 +70,7 @@ void flac__analyze_frame(const FLAC__Frame *frame, uint32_t frame_number, FLAC__
|
||||
uint32_t i, channel, partitions;
|
||||
|
||||
/* do the human-readable part first */
|
||||
fprintf(fout, "frame=%u\toffset=%" PRIu64 "\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
|
||||
fprintf(fout, "frame=%u\toffset=%" PRIu64 "\tbits=%" PRIu64 "\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
|
||||
for(channel = 0; channel < channels; channel++) {
|
||||
const FLAC__Subframe *subframe = frame->subframes+channel;
|
||||
const FLAC__bool is_rice2 = subframe->data.fixed.entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2;
|
||||
|
||||
@@ -26,7 +26,7 @@ typedef struct {
|
||||
} analysis_options;
|
||||
|
||||
void flac__analyze_init(analysis_options aopts);
|
||||
void flac__analyze_frame(const FLAC__Frame *frame, uint32_t frame_number, FLAC__uint64 frame_offset, uint32_t frame_bytes, analysis_options aopts, FILE *fout);
|
||||
void flac__analyze_frame(const FLAC__Frame *frame, uint32_t frame_number, FLAC__uint64 frame_offset, FLAC__uint64 frame_bytes, analysis_options aopts, FILE *fout);
|
||||
void flac__analyze_finish(analysis_options aopts);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1007,7 +1007,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder
|
||||
decoder_session->is_unsigned_samples
|
||||
));
|
||||
uint32_t wide_samples = frame->header.blocksize, wide_sample, sample, channel;
|
||||
uint32_t frame_bytes = 0;
|
||||
FLAC__uint64 frame_bytes = 0;
|
||||
|
||||
static union
|
||||
{ /* The arrays defined within this union are all the same size. */
|
||||
@@ -1117,7 +1117,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder
|
||||
if(decoder_session->analysis_mode) {
|
||||
FLAC__uint64 dpos;
|
||||
FLAC__stream_decoder_get_decode_position(decoder_session->decoder, &dpos);
|
||||
frame_bytes = (uint32_t)(dpos-decoder_session->decode_position);
|
||||
frame_bytes = (dpos-decoder_session->decode_position);
|
||||
decoder_session->decode_position = dpos;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user