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;
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).
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;
#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();
#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,
#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)];
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)];
//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);
//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);
}
}
//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);
}
}