]> git.sesse.net Git - narabu/commitdiff
Activate the same-block optimization for the GPU encoder, too.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 17 Oct 2017 21:01:01 +0000 (23:01 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 17 Oct 2017 21:01:01 +0000 (23:01 +0200)
narabu-encoder.cpp

index b53cfc074e778bac541c8a522de1b5c81f7e55b5..febe2148d2d6ed1c9499d3f9542f6394d8282f94 100644 (file)
@@ -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);
                        }
                }
        }