mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-18 18:57:57 -05:00
Make sure xchunk write size can specified to be smaller than xchunk size to respect zlib to add size instead of removing size due to not being able to compress
This commit is contained in:
@ -55,9 +55,10 @@ void OutputProcessorXChunks::WriteChunk()
|
||||
m_current_stream = (m_current_stream + 1) % m_stream_count;
|
||||
}
|
||||
|
||||
OutputProcessorXChunks::OutputProcessorXChunks(const int numStreams, const size_t xChunkSize)
|
||||
OutputProcessorXChunks::OutputProcessorXChunks(const int numStreams, const size_t xChunkSize, const size_t xChunkWriteSize)
|
||||
: m_stream_count(numStreams),
|
||||
m_chunk_size(xChunkSize),
|
||||
m_chunk_write_size(xChunkWriteSize),
|
||||
m_vanilla_buffer_size(0),
|
||||
m_initialized(false),
|
||||
m_current_stream(0),
|
||||
@ -68,6 +69,7 @@ OutputProcessorXChunks::OutputProcessorXChunks(const int numStreams, const size_
|
||||
{
|
||||
assert(numStreams > 0);
|
||||
assert(xChunkSize > 0);
|
||||
assert(m_chunk_size >= m_chunk_write_size);
|
||||
|
||||
for (auto i = 0u; i < 2u; i++)
|
||||
m_buffers.emplace_back(std::make_unique<uint8_t[]>(xChunkSize));
|
||||
@ -76,8 +78,8 @@ OutputProcessorXChunks::OutputProcessorXChunks(const int numStreams, const size_
|
||||
m_output_buffer = m_buffers[1].get();
|
||||
}
|
||||
|
||||
OutputProcessorXChunks::OutputProcessorXChunks(const int numStreams, const size_t xChunkSize, const size_t vanillaBufferSize)
|
||||
: OutputProcessorXChunks(numStreams, xChunkSize)
|
||||
OutputProcessorXChunks::OutputProcessorXChunks(const int numStreams, const size_t xChunkSize, const size_t xChunkWriteSize, const size_t vanillaBufferSize)
|
||||
: OutputProcessorXChunks(numStreams, xChunkSize, xChunkWriteSize)
|
||||
{
|
||||
m_vanilla_buffer_size = vanillaBufferSize;
|
||||
}
|
||||
@ -99,11 +101,11 @@ void OutputProcessorXChunks::Write(const void* buffer, const size_t length)
|
||||
auto sizeRemaining = length;
|
||||
while (sizeRemaining > 0)
|
||||
{
|
||||
const auto toWrite = std::min(m_chunk_size - m_input_size, sizeRemaining);
|
||||
const auto toWrite = std::min(m_chunk_write_size - m_input_size, sizeRemaining);
|
||||
|
||||
memcpy(&m_input_buffer[m_input_size], &static_cast<const char*>(buffer)[length - sizeRemaining], toWrite);
|
||||
m_input_size += toWrite;
|
||||
if (m_input_size >= m_chunk_size)
|
||||
if (m_input_size >= m_chunk_write_size)
|
||||
WriteChunk();
|
||||
|
||||
sizeRemaining -= toWrite;
|
||||
|
@ -13,6 +13,7 @@ class OutputProcessorXChunks final : public OutputStreamProcessor
|
||||
|
||||
int m_stream_count;
|
||||
size_t m_chunk_size;
|
||||
size_t m_chunk_write_size;
|
||||
size_t m_vanilla_buffer_size;
|
||||
|
||||
bool m_initialized;
|
||||
@ -28,8 +29,8 @@ class OutputProcessorXChunks final : public OutputStreamProcessor
|
||||
void WriteChunk();
|
||||
|
||||
public:
|
||||
OutputProcessorXChunks(int numStreams, size_t xChunkSize);
|
||||
OutputProcessorXChunks(int numStreams, size_t xChunkSize, size_t vanillaBufferSize);
|
||||
OutputProcessorXChunks(int numStreams, size_t xChunkSize, size_t xChunkWriteSize);
|
||||
OutputProcessorXChunks(int numStreams, size_t xChunkSize, size_t xChunkWriteSize, size_t vanillaBufferSize);
|
||||
~OutputProcessorXChunks() override = default;
|
||||
|
||||
OutputProcessorXChunks(const OutputProcessorXChunks& other) = delete;
|
||||
|
Reference in New Issue
Block a user