From 38b7fec1430e07a674ef1701e25fcfc4fae87a11 Mon Sep 17 00:00:00 2001 From: Martijn van Beurden Date: Sun, 5 Jul 2020 19:29:35 +0200 Subject: 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. --- src/flac/analyze.c | 4 ++-- src/flac/analyze.h | 2 +- src/flac/decode.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/flac/analyze.c b/src/flac/analyze.c index 683b6446..4c68094c 100644 --- a/src/flac/analyze.c +++ b/src/flac/analyze.c @@ -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; diff --git a/src/flac/analyze.h b/src/flac/analyze.h index 44798c71..fed0ee23 100644 --- a/src/flac/analyze.h +++ b/src/flac/analyze.h @@ -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 diff --git a/src/flac/decode.c b/src/flac/decode.c index 1a8f28e9..517b1bba 100644 --- a/src/flac/decode.c +++ b/src/flac/decode.c @@ -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; } -- cgit v1.2.1