]> git.sesse.net Git - narabu/commitdiff
Make blocks per stream a named constant.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 24 Sep 2017 17:39:25 +0000 (19:39 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 24 Sep 2017 17:39:25 +0000 (19:39 +0200)
decoder.shader
narabu.cpp
qdc.cpp

index 724a2f5f38362538adab6750d83297f96c440d24..3b721264b4026f5a6b9cbb6e9c6a5749b15bd30e 100644 (file)
@@ -16,6 +16,7 @@ const uint prob_bits = 12;
 const uint prob_scale = 1 << prob_bits;
 const uint NUM_SYMS = 256;
 const uint ESCAPE_LIMIT = NUM_SYMS - 1;
+const uint BLOCKS_PER_STREAM = 320;
 
 // These need to be folded into quant_matrix.
 const float dc_scalefac = 8.0;
@@ -230,7 +231,7 @@ void main()
 
        pick_timer(start, local_timing[0]);
 
-       for (uint block_idx = 40; block_idx --> 0; ) {
+       for (uint block_idx = BLOCKS_PER_STREAM / 8; block_idx --> 0; ) {
                pick_timer(start, local_timing[1]);
 
                // rANS decode one coefficient across eight blocks (so 64x8 coefficients).
index 11117f4fd9f9c744e62b4fe15a7b06b365120812..898f7efeec4b343a7b011bcea85b8376a223873a 100644 (file)
@@ -24,6 +24,7 @@ const unsigned prob_bits = 12;
 const unsigned prob_scale = 1 << prob_bits;
 const unsigned NUM_SYMS = 256;
 const unsigned NUM_TABLES = 8;
+const unsigned BLOCKS_PER_STREAM = 320;
 
 struct RansDecSymbol {
         unsigned sym_start;
@@ -266,7 +267,7 @@ int main(int argc, char **argv)
 #define PARALLEL_SLICES 1
        steady_clock::time_point start = steady_clock::now();
        for (int i = 0; i < 1000; ++i) {
-               unsigned num_slices = (WIDTH/8)*(HEIGHT/8)/320;
+               unsigned num_slices = (WIDTH/8)*(HEIGHT/8)/BLOCKS_PER_STREAM;
                glDispatchCompute(1, (num_slices+PARALLEL_SLICES-1)/PARALLEL_SLICES, 1);
        }
        check_error();
diff --git a/qdc.cpp b/qdc.cpp
index 5a4a9d506195586ec9c56d2893621c0f69379233..a0919bd750d476e0e6aace471532fafedf4df94c 100644 (file)
--- a/qdc.cpp
+++ b/qdc.cpp
 #define HEIGHT_BLOCKS (HEIGHT/8)
 #define NUM_BLOCKS (WIDTH_BLOCKS * HEIGHT_BLOCKS)
 #define NUM_BLOCKS_CHROMA (WIDTH_BLOCKS_CHROMA * HEIGHT_BLOCKS)
+
 #define NUM_SYMS 256
 #define ESCAPE_LIMIT (NUM_SYMS - 1)
+#define BLOCKS_PER_STREAM 320
 
 // If you set this to 1, the program will try to optimize the placement
 // of coefficients to rANS probability distributions. This is randomized,
@@ -720,10 +722,10 @@ int main(int argc, char **argv)
 #endif
 
        // DC coefficient pred from the right to left (within each slice)
-       for (unsigned block_idx = 0; block_idx < NUM_BLOCKS; block_idx += 320) {
+       for (unsigned block_idx = 0; block_idx < NUM_BLOCKS; block_idx += BLOCKS_PER_STREAM) {
                int prev_k = 128;
 
-               for (unsigned subblock_idx = 320; subblock_idx --> 0; ) {
+               for (unsigned subblock_idx = BLOCKS_PER_STREAM; subblock_idx --> 0; ) {
                        unsigned yb = (block_idx + subblock_idx) / WIDTH_BLOCKS;
                        unsigned xb = (block_idx + subblock_idx) % WIDTH_BLOCKS;
                        int k = coeff_y[(yb * 8) * WIDTH + (xb * 8)];
@@ -733,11 +735,11 @@ int main(int argc, char **argv)
                        prev_k = k;
                }
        }
-       for (unsigned block_idx = 0; block_idx < NUM_BLOCKS_CHROMA; block_idx += 320) {
+       for (unsigned block_idx = 0; block_idx < NUM_BLOCKS_CHROMA; block_idx += BLOCKS_PER_STREAM) {
                int prev_k_cb = 0;
                int prev_k_cr = 0;
 
-               for (unsigned subblock_idx = 320; subblock_idx --> 0; ) {
+               for (unsigned subblock_idx = BLOCKS_PER_STREAM; subblock_idx --> 0; ) {
                        unsigned yb = (block_idx + subblock_idx) / WIDTH_BLOCKS_CHROMA;
                        unsigned xb = (block_idx + subblock_idx) % WIDTH_BLOCKS_CHROMA;
                        int k_cb = coeff_cb[(yb * 8) * WIDTH/2 + (xb * 8)];
@@ -880,7 +882,7 @@ int main(int argc, char **argv)
                                //printf("encoding coeff %d xb,yb=%d,%d: %d\n", y*8+x, xb, yb, k);
                                rans_encoder.encode_coeff(k);
 
-                               if (block_idx % 320 == 319 || block_idx == NUM_BLOCKS - 1) {
+                               if (block_idx % BLOCKS_PER_STREAM == (BLOCKS_PER_STREAM - 1) || block_idx == NUM_BLOCKS - 1) {
                                        int l = rans_encoder.save_block(codedfp);
                                        num_bytes += l;
                                        lens.push_back(l);
@@ -920,7 +922,7 @@ int main(int argc, char **argv)
                                //printf("encoding coeff %d xb,yb=%d,%d: %d\n", y*8+x, xb, yb, k);
                                rans_encoder.encode_coeff(k);
 
-                               if (block_idx % 320 == 319 || block_idx == NUM_BLOCKS - 1) {
+                               if (block_idx % BLOCKS_PER_STREAM == (BLOCKS_PER_STREAM - 1) || block_idx == NUM_BLOCKS - 1) {
                                        num_bytes += rans_encoder.save_block(codedfp);
                                }
                        }
@@ -945,7 +947,7 @@ int main(int argc, char **argv)
                                //printf("encoding coeff %d xb,yb=%d,%d: %d\n", y*8+x, xb, yb, k);
                                rans_encoder.encode_coeff(k);
 
-                               if (block_idx % 320 == 319 || block_idx == NUM_BLOCKS - 1) {
+                               if (block_idx % BLOCKS_PER_STREAM == (BLOCKS_PER_STREAM - 1) || block_idx == NUM_BLOCKS - 1) {
                                        num_bytes += rans_encoder.save_block(codedfp);
                                }
                        }