From cff71c88ac8856c183fb3d787ea2d9d834fc3dc7 Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Fri, 13 Apr 2001 18:20:23 +0000 Subject: [PATCH] skip seekpoint placeholders --- src/libFLAC/stream_decoder.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c index 79cd2775..ff866d0d 100644 --- a/src/libFLAC/stream_decoder.c +++ b/src/libFLAC/stream_decoder.c @@ -533,6 +533,8 @@ bool stream_decoder_read_metadata_(FLAC__StreamDecoder *decoder) decoder->guts->metadata_callback(decoder, &decoder->guts->stream_info, decoder->guts->client_data); } else if(type == FLAC__METADATA_TYPE_SEEKTABLE) { + unsigned real_points; + decoder->guts->seek_table.type = type; decoder->guts->seek_table.is_last = last_block; decoder->guts->seek_table.length = length; @@ -543,19 +545,23 @@ bool stream_decoder_read_metadata_(FLAC__StreamDecoder *decoder) decoder->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; return false; } - for(i = 0; i < decoder->guts->seek_table.data.seek_table.num_points; i++) { + for(i = real_points = 0; i < decoder->guts->seek_table.data.seek_table.num_points; i++) { if(!FLAC__bitbuffer_read_raw_uint64(&decoder->guts->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN, read_callback_, decoder)) return false; /* the read_callback_ sets the state for us */ - decoder->guts->seek_table.data.seek_table.points[i].sample_number = xx; + decoder->guts->seek_table.data.seek_table.points[real_points].sample_number = xx; if(!FLAC__bitbuffer_read_raw_uint64(&decoder->guts->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN, read_callback_, decoder)) return false; /* the read_callback_ sets the state for us */ - decoder->guts->seek_table.data.seek_table.points[i].stream_offset = xx; + decoder->guts->seek_table.data.seek_table.points[real_points].stream_offset = xx; - if(!FLAC__bitbuffer_read_raw_uint32(&decoder->guts->input, &x, FLAC__STREAM_METADATA_SEEKPOINT_BLOCK_OFFSET_LEN, read_callback_, decoder)) + if(!FLAC__bitbuffer_read_raw_uint32(&decoder->guts->input, &x, FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN, read_callback_, decoder)) return false; /* the read_callback_ sets the state for us */ - decoder->guts->seek_table.data.seek_table.points[i].block_offset = x; + decoder->guts->seek_table.data.seek_table.points[real_points].frame_samples = x; + + if(decoder->guts->seek_table.data.seek_table.points[real_points].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) + real_points++; } + decoder->guts->seek_table.data.seek_table.num_points = real_points; decoder->guts->has_seek_table = true; decoder->guts->metadata_callback(decoder, &decoder->guts->seek_table, decoder->guts->client_data);