Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions openvdb/openvdb/io/Compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -643,15 +643,15 @@ writeCompressedValuesSize(ValueT* srcBuf, Index srcCount,
/// @param toHalf if true, convert floating-point values to 16-bit half floats
template<typename ValueT, typename MaskT>
inline void
writeCompressedValues(std::ostream& os, ValueT* srcBuf, Index srcCount,
writeCompressedValues(std::ostream& os, const ValueT* srcBuf, Index srcCount,
const MaskT& valueMask, const MaskT& childMask, bool toHalf)
{
// Get the stream's compression settings.
const uint32_t compress = getDataCompression(os);
const bool maskCompress = compress & COMPRESS_ACTIVE_MASK;

Index tempCount = srcCount;
ValueT* tempBuf = srcBuf;
ValueT* tempBuf = nullptr;
std::unique_ptr<ValueT[]> scopedTempBuf;

int8_t metadata = NO_MASK_AND_ALL_VALS;
Expand Down Expand Up @@ -743,9 +743,10 @@ writeCompressedValues(std::ostream& os, ValueT* srcBuf, Index srcCount,

// Write out the buffer.
if (toHalf) {
HalfWriter<RealToHalf<ValueT>::isReal, ValueT>::write(os, tempBuf, tempCount, compress);
HalfWriter<RealToHalf<ValueT>::isReal, ValueT>::write(os,
bool(tempBuf) ? tempBuf : srcBuf, tempCount, compress);
} else {
writeData(os, tempBuf, tempCount, compress);
writeData(os, bool(tempBuf) ? tempBuf : srcBuf, tempCount, compress);
}
}

Expand Down
2 changes: 1 addition & 1 deletion openvdb/openvdb/points/PointDataGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ readCompressedValues( std::istream& is, PointDataIndex32* destBuf, Index destC
/// ignore the value mask, use a larger block size and use 16-bit size instead of 64-bit
template<>
inline void
writeCompressedValues( std::ostream& os, PointDataIndex32* srcBuf, Index srcCount,
writeCompressedValues( std::ostream& os, const PointDataIndex32* srcBuf, Index srcCount,
const util::NodeMask<3>& /*valueMask*/,
const util::NodeMask<3>& /*childMask*/, bool /*toHalf*/)
{
Expand Down
3 changes: 3 additions & 0 deletions pendingchanges/write_compressed_const.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
API Changes:
- io::writeCompressedValues() now takes a const ValueT* source buffer for
improved const-correctness.
Loading