]> git.sesse.net Git - narabu/blobdiff - narabu.cpp
More fixes of hard-coded values.
[narabu] / narabu.cpp
index bb1209c7fc3ebe7c4bf66123567736cb6bff3854..0ac4f71d75ab58794da432e64c22ea0811cdb437 100644 (file)
@@ -223,6 +223,7 @@ int main(int argc, char **argv)
        printf("%d err=0x%x\n", __LINE__, glGetError());
 
        // Decode all luma blocks.
+       size_t last_src_offset = 0, last_src_len = 0;
        for (unsigned y = 0; y < 8; ++y) {
                 for (unsigned x = 0; x < 8; ++x) {
                        unsigned coeff_num = y * 8 + x;
@@ -235,8 +236,16 @@ int main(int argc, char **argv)
                                }
 
                                CoeffStream *stream = &streams[coeff_num * num_blocks + block_idx / BLOCKS_PER_STREAM];
-                               stream->src_offset = ptr - coded.data();
-                               stream->src_len = *num_rans_bytes;
+                               if (*num_rans_bytes == 0) {
+                                       // Repeat last stream.
+                                       stream->src_offset = last_src_offset;
+                                       stream->src_len = last_src_len;
+                               } else {
+                                       stream->src_offset = ptr - coded.data();
+                                       stream->src_len = *num_rans_bytes;
+                                       last_src_offset = stream->src_offset;
+                                       last_src_len = last_src_len;
+                               }
 
                                // TODO: check len
                                ptr += *num_rans_bytes;