From: Steinar H. Gunderson Date: Tue, 17 Oct 2017 21:01:01 +0000 (+0200) Subject: Activate the same-block optimization for the GPU encoder, too. X-Git-Url: https://git.sesse.net/?p=narabu;a=commitdiff_plain;h=016d6ce14089a2f3518500adf80f155f1f14a4d2 Activate the same-block optimization for the GPU encoder, too. --- diff --git a/narabu-encoder.cpp b/narabu-encoder.cpp index b53cfc0..febe214 100644 --- a/narabu-encoder.cpp +++ b/narabu-encoder.cpp @@ -394,25 +394,22 @@ int main(int argc, char **argv) const uint8_t *data = (const uint8_t *)glMapNamedBufferRange(output_ssbo, 0, 45 * 64 * 1024, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT); + string last_block; for (unsigned y = 0; y < 8; ++y) { for (unsigned x = 0; x < 8; ++x) { for (unsigned int stream_idx = 0; stream_idx < 45; ++stream_idx) { const uint8_t *out_end = data + (stream_idx * 64 + y * 8 + x + 1) * 1024; const uint8_t *ptr = data + offsets[stream_idx * 64 + y * 8 + x]; uint32_t num_rans_bytes = out_end - ptr; -#if 0 + if (num_rans_bytes == last_block.size() && memcmp(last_block.data(), ptr, last_block.size()) == 0) { write_varint(0, codedfp); - clear(); - return 1; } else { last_block = string((const char *)ptr, num_rans_bytes); + write_varint(num_rans_bytes, codedfp); + fwrite(ptr, 1, num_rans_bytes, codedfp); } -#endif - - write_varint(num_rans_bytes, codedfp); - fwrite(ptr, 1, num_rans_bytes, codedfp); } } }