mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-11-10 20:10:05 +00:00
Fix wrong buffer size
This commit is contained in:
parent
33067d631d
commit
b368942463
@ -41,6 +41,7 @@ IONGSMSFileSource::IONGSMSFileSource(
|
||||
file_metadata_(file),
|
||||
block_metadata_(block),
|
||||
io_buffer_offset_(0),
|
||||
maximum_item_rate_(0),
|
||||
chunk_cycle_length_(0)
|
||||
{
|
||||
std::filesystem::path data_filepath = metadata_filepath.parent_path() / file.Url().Value();
|
||||
@ -58,11 +59,10 @@ IONGSMSFileSource::IONGSMSFileSource(
|
||||
for (std::size_t i = 0; i < out_count; ++i)
|
||||
{
|
||||
output_stream_item_sizes_.push_back(chunk_data_.back()->output_stream_item_size(i));
|
||||
maximum_item_rate_ = std::max(chunk_data_.back()->output_stream_item_rate(i), maximum_item_rate_);
|
||||
}
|
||||
}
|
||||
output_stream_count_ = output_stream_offset;
|
||||
|
||||
io_buffer_.resize((16*1024 - 1) * chunk_cycle_length_);
|
||||
}
|
||||
|
||||
IONGSMSFileSource::~IONGSMSFileSource()
|
||||
@ -75,6 +75,8 @@ int IONGSMSFileSource::work(
|
||||
gr_vector_const_void_star& input_items,
|
||||
gr_vector_void_star& output_items)
|
||||
{
|
||||
const std::size_t max_sample_output = std::floor((noutput_items-1.0) / maximum_item_rate_);
|
||||
io_buffer_.resize(max_sample_output * chunk_cycle_length_);
|
||||
io_buffer_offset_ = 0;
|
||||
std::fread(io_buffer_.data(), sizeof(decltype(io_buffer_)::value_type), io_buffer_.size(), fd_);
|
||||
|
||||
|
@ -62,6 +62,7 @@ private:
|
||||
std::vector<int> items_produced_;
|
||||
std::size_t output_stream_count_;
|
||||
std::vector<std::size_t> output_stream_item_sizes_;
|
||||
std::size_t maximum_item_rate_;
|
||||
std::vector<std::shared_ptr<IONGSMSChunkData>> chunk_data_;
|
||||
std::size_t chunk_cycle_length_;
|
||||
};
|
||||
|
@ -49,12 +49,15 @@ IONGSMSChunkData::IONGSMSChunkData(const GnssMetadata::Chunk& chunk, const std::
|
||||
streams_.emplace_back(lump, stream, GnssMetadata::encoding_from_string(stream.Encoding()),output_streams + output_stream_offset);
|
||||
++output_streams;
|
||||
std::size_t sample_bitsize = stream.Packedbits() / stream.RateFactor();
|
||||
std::size_t sample_rate = stream.RateFactor();
|
||||
if (stream.Packedbits() >= 2 * stream.RateFactor() * stream.Quantization())
|
||||
{
|
||||
// Samples have 'Complex' format
|
||||
sample_bitsize /= 2;
|
||||
sample_rate *= 2;
|
||||
}
|
||||
output_stream_item_size_.push_back(bits_to_item_size(sample_bitsize));
|
||||
output_stream_item_rate_.push_back(sample_rate);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -116,6 +119,11 @@ std::size_t IONGSMSChunkData::output_stream_item_size(std::size_t stream_index)
|
||||
return output_stream_item_size_[stream_index];
|
||||
}
|
||||
|
||||
std::size_t IONGSMSChunkData::output_stream_item_rate(std::size_t stream_index) const
|
||||
{
|
||||
return output_stream_item_rate_[stream_index];
|
||||
}
|
||||
|
||||
|
||||
template <typename WT>
|
||||
void IONGSMSChunkData::unpack_words(gr_vector_void_star& outputs, std::vector<int>& output_items)
|
||||
|
@ -93,6 +93,7 @@ public:
|
||||
|
||||
std::size_t output_stream_count() const;
|
||||
std::size_t output_stream_item_size(std::size_t stream_index) const;
|
||||
std::size_t output_stream_item_rate(std::size_t stream_index) const;
|
||||
|
||||
private:
|
||||
template <typename WT>
|
||||
@ -126,6 +127,7 @@ private:
|
||||
uint8_t padding_bitsize_;
|
||||
std::size_t output_stream_count_;
|
||||
std::vector<std::size_t> output_stream_item_size_;
|
||||
std::vector<std::size_t> output_stream_item_rate_;
|
||||
|
||||
struct stream_metadata_t
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user