mirror of https://github.com/xiph/flac
add checking based on number_type in the frame header
This commit is contained in:
parent
9608463921
commit
0fb3ee8f62
|
@ -1112,6 +1112,7 @@ FLAC__StreamDecoderWriteStatus verify_write_callback(const FLAC__StreamDecoder *
|
|||
}
|
||||
}
|
||||
FLAC__ASSERT(l < r);
|
||||
FLAC__ASSERT(frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
|
||||
fprintf(stderr, " Absolute sample=%u, frame=%u, channel=%u, sample=%u, expected %d, got %d\n", (unsigned)frame->header.number.sample_number + sample, (unsigned)frame->header.number.sample_number / FLAC__stream_decoder_get_blocksize(decoder), channel, sample, expect, got); /*@@@ WATCHOUT: 4GB limit */
|
||||
return FLAC__STREAM_DECODER_WRITE_ABORT;
|
||||
}
|
||||
|
|
|
@ -441,6 +441,8 @@ FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decode
|
|||
FLAC__uint64 next_frame_sample = this_frame_sample + (FLAC__uint64)frame->header.blocksize;
|
||||
FLAC__uint64 target_sample = file_decoder->private->target_sample;
|
||||
|
||||
FLAC__ASSERT(frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
|
||||
|
||||
file_decoder->private->last_frame = *frame; /* save the frame in the private */
|
||||
if(this_frame_sample <= target_sample && target_sample < next_frame_sample) { /* we hit our target frame */
|
||||
unsigned delta = (unsigned)(target_sample - this_frame_sample);
|
||||
|
@ -639,6 +641,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, F
|
|||
}
|
||||
else { /* we need to narrow the search */
|
||||
FLAC__uint64 this_frame_sample = decoder->private->last_frame.header.number.sample_number;
|
||||
FLAC__ASSERT(decoder->private->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
|
||||
if(this_frame_sample == last_frame_sample) {
|
||||
/* our last move backwards wasn't big enough */
|
||||
pos -= (last_pos - pos);
|
||||
|
|
|
@ -941,6 +941,7 @@ FLAC__bool stream_decoder_read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *
|
|||
decoder->protected->sample_rate = decoder->private->frame.header.sample_rate;
|
||||
decoder->protected->blocksize = decoder->private->frame.header.blocksize;
|
||||
|
||||
FLAC__ASSERT(decoder->private->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
|
||||
decoder->private->samples_decoded = decoder->private->frame.header.number.sample_number + decoder->private->frame.header.blocksize;
|
||||
|
||||
/* write it */
|
||||
|
@ -1154,6 +1155,7 @@ FLAC__bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *decoder)
|
|||
decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
|
||||
return true;
|
||||
}
|
||||
decoder->private->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER;
|
||||
decoder->private->frame.header.number.sample_number = xx;
|
||||
}
|
||||
else {
|
||||
|
@ -1168,6 +1170,7 @@ FLAC__bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *decoder)
|
|||
}
|
||||
decoder->private->last_frame_number = x;
|
||||
if(decoder->private->has_stream_info) {
|
||||
decoder->private->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER;
|
||||
decoder->private->frame.header.number.sample_number = (FLAC__int64)decoder->private->stream_info.data.stream_info.min_blocksize * (FLAC__int64)x;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -222,6 +222,7 @@ FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__bool st
|
|||
if(!FLAC__bitbuffer_write_raw_uint32(bb, 0, FLAC__FRAME_HEADER_ZERO_PAD_LEN))
|
||||
return false;
|
||||
|
||||
FLAC__ASSERT(header->number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER);
|
||||
if(!FLAC__bitbuffer_write_utf8_uint32(bb, header->number.frame_number))
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue